Sourceforge.net - The VCF's Project Host
   The VCF Website Home   |   Online Discussion Forums   |   Sourceforge.net Project Page   

VCF::Condition Class Reference

The Condition object is used as a synchronization primitive, like the Mutex, and Semaphore. More...

#include <vcf/FoundationKit/Condition.h>

Inheritance diagram for VCF::Condition:

VCF::Object VCF::Waitable List of all members.

Public Member Functions

 Condition (Mutex *mutex)
 Every condtion must be associated with a mutex.
virtual ~Condition ()
void signal ()
 Signal one waiting thread that condition is true.
virtual void broadcast ()
ConditionPeergetPeer ()
virtual Waitable::WaitResult wait ()
 Wait forever until the condition is signaled.
Waitable::WaitResult wait (uint32 milliseconds)
 Wait for a maximum number of milliseconds until the condition is signaled.
OSHandleID getPeerHandleID ()
MutexgetMutex ()
 Returns the mutex associated with the condition.

Protected Attributes

Mutexmutex_
ConditionPeerpeer_

Detailed Description

The Condition object is used as a synchronization primitive, like the Mutex, and Semaphore.

While the Mutex and Semaphore can cause multiple threads to block, waiting for the mutex or semaphore to become signaled, only one thread will every wake at any given moment. In contrast, a Condition can be used to wake up a series of threads all waiting on the condition.

The Condition class follows the same pattern that the Pthreads condition variable uses, or the Boost condition class. In fact, the Win32 implementation is written largely based of off the excellent code in the Boost condition class that was written by William Kempf.


Constructor & Destructor Documentation

VCF::Condition::Condition Mutex mutex  ) 
 

Every condtion must be associated with a mutex.

virtual VCF::Condition::~Condition  )  [virtual]
 


Member Function Documentation

virtual void VCF::Condition::broadcast  )  [virtual]
 

Mutex* VCF::Condition::getMutex  )  [inline]
 

Returns the mutex associated with the condition.

ConditionPeer* VCF::Condition::getPeer  )  [inline]
 

OSHandleID VCF::Condition::getPeerHandleID  )  [virtual]
 

Implements VCF::Waitable.

void VCF::Condition::signal  ) 
 

Signal one waiting thread that condition is true.

Waitable::WaitResult VCF::Condition::wait uint32  milliseconds  )  [virtual]
 

Wait for a maximum number of milliseconds until the condition is signaled.

The thread that calls this will block till the condition is signaled. If the condition is signaled before the timeout period is ellapsed the function will return Waitable::wrTimeout value.

Implements VCF::Waitable.

virtual Waitable::WaitResult VCF::Condition::wait  )  [virtual]
 

Wait forever until the condition is signaled.

The thread that calls this will block till the condition is signaled. If the wait fails the method will return Waitable::wrFail

Implements VCF::Waitable.


Member Data Documentation

Mutex* VCF::Condition::mutex_ [protected]
 

ConditionPeer* VCF::Condition::peer_ [protected]
 


The documentation for this class was generated from the following file:
   Comments or Suggestions?    License Information