A condition variable is a synchronization device that allows threads to suspend execution until some predicate on shared data is satisfied. More...
#include <SGThread.hxx>
Public Member Functions | |
SGPthreadCond () | |
Create a new condition variable. | |
~SGPthreadCond () | |
Destroy the condition object. | |
void | wait (SGMutex &) |
Wait for this condition variable to be signaled. | |
bool | wait (SGMutex &mutex, unsigned long ms) |
Wait for this condition variable to be signaled for at most 'ms' milliseconds. | |
void | signal () |
Wake one thread waiting on this condition variable. | |
void | broadcast () |
Wake all threads waiting on this condition variable. |
A condition variable is a synchronization device that allows threads to suspend execution until some predicate on shared data is satisfied.
A condition variable is always associated with a mutex to avoid race conditions.
Definition at line 250 of file SGThread.hxx.
void SGPthreadCond::broadcast | ( | ) | [inline] |
Wake all threads waiting on this condition variable.
Nothing happens if no threads are waiting.
Definition at line 329 of file SGThread.hxx.
void SGPthreadCond::signal | ( | ) | [inline] |
Wake one thread waiting on this condition variable.
Nothing happens if no threads are waiting. If several threads are waiting exactly one thread is restarted. It is not specified which.
Definition at line 322 of file SGThread.hxx.
bool SGPthreadCond::wait | ( | SGMutex & | mutex, | |
unsigned long | ms | |||
) |
Wait for this condition variable to be signaled for at most 'ms' milliseconds.
mutex | reference to a locked mutex. | |
ms | milliseconds to wait for a signal. |
Definition at line 86 of file SGThread.cxx.
void SGPthreadCond::wait | ( | SGMutex & | mutex | ) | [inline] |
Wait for this condition variable to be signaled.
SGMutex& | reference to a locked mutex. |
Definition at line 336 of file SGThread.hxx.