Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members  

mpcl::system::ICondition Class Reference

#include <condition.hh>

Inheritance diagram for mpcl::system::ICondition:

mpcl::system::TCondition List of all members.

Public Methods

virtual ~ICondition (void)
 Destroys the instance.

virtual void wait (void)=0
virtual bool timedWait (size_t zSECONDS, size_t zNANOSECONDS=0)=0
virtual void signal (void)=0
virtual void broadcast (void)=0

Detailed Description

Condition base class.

A condition (short for "condition variable") is a synchronization device that allows threads to suspend execution and relinquish the processors until some predicate on shared data is satisfied. The basic operations on conditions are: signal the condition (when the predicate becomes true), and wait for the condition, suspending the thread execution until another thread signals the condition.

A condition variable must always be associated with a mutex, to avoid the race condition where a thread prepares to wait on a condition variable and another thread signals the condition just before the first thread actually waits on it.

See also:
TBaseOperatingSystem, TBaseMutex.

Definition at line 57 of file condition.hh.


Member Function Documentation

virtual void mpcl::system::ICondition::broadcast void    [pure virtual]
 

Restarts all the threads that are waiting on this condition variable. Nothing happens if no threads are waiting on this.

Implemented in mpcl::system::TCondition.

virtual void mpcl::system::ICondition::signal void    [pure virtual]
 

Restarts one of the threads that are waiting on this condition variable If no threads are waiting on this, nothing happens. If several threads are waiting on this, exactly one is restarted, but it is not specified which.

Implemented in mpcl::system::TCondition.

virtual bool mpcl::system::ICondition::timedWait size_t    zSECONDS,
size_t    zNANOSECONDS = 0
[pure virtual]
 

Atomically unlocks the related mutex and waits on this variable, as wait() does, but it also bounds the duration of the wait. If this condition has not been signaled within the amount of time specified in parameters, the former mutex is re-acquired and returns true. In any case the thread will re-acquire the externally supplied mutex.

Parameters:
zSECONDS  Seconds to wait for.
zNANOSECONDS  Nanoseconds to wait for.
Returns:
True if time has been reached or exceeded.
See also:
wait(), TBaseMutex.

Implemented in mpcl::system::TCondition.

virtual void mpcl::system::ICondition::wait void    [pure virtual]
 

Atomically unlocks the associated mutex (as per member function TBaseMutex::unlock()) and waits for this condition variable to be signaled. The thread execution is suspended and does not consume any CPU time until this condition variable is signaled. That mutex must be locked by the calling thread on entrance to this member function. Before returning to the calling thread, this member function re-acquires mutex (as per member function TBaseMutex::lock()). This member function seems like is prefixed with a TBaseMutex::unlock() and postfixed with a TBaseMutex::lock() over the related mutex.

See also:
signal(), broadcast(), TBaseMutex.

Implemented in mpcl::system::TCondition.


The documentation for this class was generated from the following file:
Generated on Mon Oct 13 02:35:25 2003 for MPCL by doxygen1.2.18