![]() |
Public API Reference |
![]() |
#include <csutil/threading/condition.h>
Public Member Functions | |
void | NotifyAll () |
Notify and wake up all threads currently waiting for the condition. | |
void | NotifyOne () |
Notify and wake up one thread waiting for the condition. | |
template<typename LockType > | |
bool | Wait (LockType &lock, csTicks timeout=0) |
Wait for some change of condition. |
Condition variable.
A condition variable is a synchronization primitive used to have threads wait for a shared state variable to attain a given value.
Definition at line 43 of file condition.h.
void CS::Threading::Condition::NotifyAll | ( | ) | [inline] |
Notify and wake up all threads currently waiting for the condition.
The order different threads get woke up is indeterminate.
Definition at line 63 of file condition.h.
void CS::Threading::Condition::NotifyOne | ( | ) | [inline] |
Notify and wake up one thread waiting for the condition.
Definition at line 54 of file condition.h.
bool CS::Threading::Condition::Wait | ( | LockType & | lock, |
csTicks | timeout = 0 |
||
) | [inline] |
Wait for some change of condition.
Suspends the calling thread until some other thread invokes Notify() or NotifyAll() to notify a change of condition.
lock | The mutex to associate with this condition. The caller must already hold a lock on the mutex before calling Wait(), and all threads waiting on the condition must be using the same mutex. The mutex must not be locked recursively within the same thread. When called, Wait() releases the caller's lock on the mutex and suspends the caller's thread. Upon return from Wait(), the caller's lock on the mutex is restored. |
timeout | Timeout in milliseconds for the wait. A value of 0 means infinite wait. |
true
when the condition was changed, or false
if the wait timed out. Definition at line 93 of file condition.h.