Threads can wait on conditions (using the wait() method), and other threads can signal or broadcast the condition to let waiting threads continue execution. This is the standard event semaphore paradigm. The condition represents an 'auto mode' event, that either lets one waiting thread go (signal) or lets all waiting threads go (broadcast.) Once the signal or broadcast completes, it resets itself automatically (as apposed to a manual mode event that stays triggered until it is manually reset.)
To also support monitor/condition type of services, there is an alternative form of the wait() method that takes a resource lock. While the thread is in the condition wait, the resource lock is unlocked. This lets multiple threads fight over a single resource while simultaneously being blocked periodically on a condition. The resource object that is locked by the passed resource lock is unwound as many times as necessary to unlock the resource. When the thread wakes up from the condition wait then it will continue to block until it can regain the resource lock. Once regained, the resource is wound back up as many times as it previously was locked. Since all recursive locks must occur on the same thread, this is safe.
Construct and destruct ICondition objects.
![]() |
public:
virtual ~ICondition()
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
protected:
ICondition()
Windows | OS/2 | AIX |
Yes | Yes | Yes |
These methods define the synchronization interface for conditions.
![]() |
public:
virtual void broadcast() = 0
The derived class should override and implement the broadcast as required for the platform.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
virtual void signal() = 0
The derived class must override this method and implement the signal operation as required for the platform.
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
The derived class should put the calling thread to sleep until another thread does a signal() or broadcast() call, or until the passed timeout expires (if a signal or broadcast does not arrive within the time out period.)
public:
virtual bool wait(long timeOut = - 1) = 0
Windows | OS/2 | AIX |
Yes | Yes | Yes |
public:
virtual bool wait( IResourceLock& alock, long timeOut = - 1 ) = 0
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
static void Relock(IResourceLock&, long times)
Windows | OS/2 | AIX |
Yes | Yes | Yes |
![]() |
public:
static long Unlock(IResourceLock&)
Windows | OS/2 | AIX |
Yes | Yes | Yes |