#include <conditionVar.h>
Public Member Functions | |
ConditionVar (Mutex &mutex) | |
You must pass in a Mutex to the condition variable constructor. | |
~ConditionVar () | |
Mutex & | get_mutex () |
Returns the mutex associated with this condition variable. | |
void | wait () |
Waits on the condition. | |
void | signal () |
Informs one of the other threads who are currently blocked on wait() that the relevant condition has changed. | |
void | signal_all () |
Wakes up all of the other threads currently blocked on wait(). | |
Private Member Functions | |
ConditionVar (const ConditionVar ©) | |
Do not attempt to copy condition variables. | |
void | operator= (const ConditionVar ©) |
Do not attempt to copy condition variables. | |
Private Attributes | |
Mutex & | _mutex |
ConditionVarImpl | _impl |
A condition variable can be used to "wake up" a thread when some arbitrary condition has changed.
A condition variable is associated with a single mutex, and several condition variables may share the same mutex.
Definition at line 53 of file conditionVar.h.
|
You must pass in a Mutex to the condition variable constructor. This mutex may be shared by other condition variables, if desired. It is the caller's responsibility to ensure the Mutex object does not destruct during the lifetime of the condition variable. Definition at line 42 of file conditionVar.I. References INLINE. |
|
Definition at line 56 of file conditionVar.I. |
|
Do not attempt to copy condition variables.
Definition at line 68 of file conditionVar.I. |
|
Returns the mutex associated with this condition variable.
Definition at line 99 of file conditionVar.I. References _impl, INLINE, and ConditionVarDummyImpl::wait(). |
|
Do not attempt to copy condition variables.
Definition at line 84 of file conditionVar.I. |
|
Informs one of the other threads who are currently blocked on wait() that the relevant condition has changed. If multiple threads are currently waiting, at least one of them will be woken up, although there is no way to predict which one. The caller must be holding the mutex associated with the condition variable before making this call, which will not release the mutex. If no threads are waiting, this is a no-op: the signal is lost. Definition at line 187 of file conditionVar.I. |
|
Wakes up all of the other threads currently blocked on wait(). The caller must be holding the mutex associated with the condition variable before making this call, which will not release the mutex. Definition at line 210 of file conditionVar.I. |
|
Waits on the condition. The caller must already be holding the lock associated with the condition variable before calling this function. wait() will release the lock, then go to sleep until some other thread calls signal() on this condition variable. At that time at least one thread waiting on the same ConditionVar will grab the lock again, and then return from wait(). It is possible that wait() will return even if no one has called signal(). It is the responsibility of the calling process to verify the condition on return from wait, and possibly loop back to wait again if necessary. Note the semantics of a condition variable: the mutex must be held before wait() is called, and it will still be held when wait() returns. However, it will be temporarily released during the wait() call itself. Definition at line 152 of file conditionVar.I. |
|
Definition at line 70 of file conditionVar.h. Referenced by get_mutex(). |
|
Definition at line 69 of file conditionVar.h. Referenced by ConditionVar(). |