class ConditionVariable
ConditionVariable allows threads to suspend execution (using Wait) until they are awaken by another thread (using Signal or Broadcast methods). ConditionVariable has associated Mutex to avoid possible race conditions when entering suspended state.
void Wait(Mutex& m, int timeout_ms = -1)
Atomically unlocks m and starts waiting for Signal or Broadcast or until timeout_ms milliseconds elapses. m has to be owned by calling thread before invoking. When Signal or Broadcast are received, resumes execution and reacquires m. Negative value for timeout_ms means the waiting time is unlimited.
void Signal()
Resumes execution of single waiting thread, if any.
void Broadcast()
Resumes execution of all currently waiting threads.
class StaticConditionVariable
Variant of ConditionVariable that can be used as static or global variable without the need of initialization - it has no constructor and correctly performs the first initialization when any of methods is called. That avoids problems with initialization order or multithreaded initialization issues.
ConditionVariable& Get()
operator ConditionVariable&()
Returns the instance of ConditionVariable.
void Wait(Mutex& m)
void Signal()
void Broadcast()
Calls respective ConditionVariable methods.
|