Public Member Functions

System::Condition Class Reference

Condition class provides communication, the ability to wait for some shared resource to reach some desired state, or to signal that it has reached some state in which another thread may be interested. More...

#include <B2BITS_Condition.h>

List of all members.

Public Member Functions

void broadcast ()
 Broadcasts condition, waking all current waiters.
 Condition ()
 Constructor.
void signal ()
 Signals condition, waking one waiting thread.
bool timedWait (Mutex *apMutex, Long aTimeout)
 Waits on condition, until awaked by a signal or broadcast, or until a specified amount of time has elapsed.
void wait (Mutex *apMutex)
 Waits on condition, until awakened by a signal or broadcast.
 ~Condition ()
 Destructor.

Detailed Description

Condition class provides communication, the ability to wait for some shared resource to reach some desired state, or to signal that it has reached some state in which another thread may be interested.

Each condition variable is closely associated with a mutex that protects the state of the resource.

Note:
A conditional variable wait always returns with the mutex locked.
Warning:
Conditional variables are for signaling, not for mutual exclusion.
Note:
Conditional variables and thier predicates are "linked" - for best results, treat them that way!

Definition at line 80 of file B2BITS_Condition.h.


Constructor & Destructor Documentation

System::Condition::Condition (  )

Constructor.

Exceptions:
SystemException
System::Condition::~Condition (  )

Destructor.


Member Function Documentation

void System::Condition::broadcast (  )

Broadcasts condition, waking all current waiters.

Note:
Use when more than one waiter may respond to predicate change or if any waiting thread may not be able to respond.
Exceptions:
SystemException
void System::Condition::signal (  )

Signals condition, waking one waiting thread.

Note:
Use when any waiter can respond, and only one need respond. All waiters are equal.
Exceptions:
SystemException
bool System::Condition::timedWait ( Mutex apMutex,
Long  aTimeout 
)

Waits on condition, until awaked by a signal or broadcast, or until a specified amount of time has elapsed.

If awaked by a signal or broadcast returns true, otherwise false. The current thread must own specified mutex.

Note:
The function shall block on a condition variable. It shall be called with mutex locked by the calling thread or undefined behavior results. Upon successful return, the mutex shall have been locked and shall be owned by the calling thread.
Parameters:
aTimeoutthe maximum time to wait in milliseconds.
Exceptions:
SystemException
void System::Condition::wait ( Mutex apMutex )

Waits on condition, until awakened by a signal or broadcast.

The current thread must own specified mutex.

Exceptions:
SystemException
Note:
The function shall block on a condition variable. It shall be called with mutex locked by the calling thread or undefined behavior results. Upon successful return, the mutex shall have been locked and shall be owned by the calling thread.