This class implements a condition variable; see ConditionVar for a brief introduction to this class. More...
#include "conditionVarFull.h"
Public Member Functions | |
ConditionVarFull (Mutex &mutex) | |
You must pass in a Mutex to the condition variable constructor. More... | |
ConditionVarFull (const ConditionVarFull ©)=delete | |
Mutex & | get_mutex () const |
Returns the mutex associated with this condition variable. More... | |
ConditionVarFull & | operator= (const ConditionVarFull ©)=delete |
![]() | |
ConditionVarFullDirect (MutexDirect &mutex) | |
You must pass in a Mutex to the condition variable constructor. More... | |
ConditionVarFullDirect (const ConditionVarFullDirect ©)=delete | |
MutexDirect & | get_mutex () const |
Returns the mutex associated with this condition variable. More... | |
void | notify () |
Informs one of the other threads who are currently blocked on wait() that the relevant condition has changed. More... | |
void | notify_all () |
Informs all of the other threads who are currently blocked on wait() that the relevant condition has changed. More... | |
ConditionVarFullDirect & | operator= (const ConditionVarFullDirect ©)=delete |
void | output (std::ostream &out) const |
This method is declared virtual in ConditionVarFullDebug, but non-virtual in ConditionVarFullDirect. More... | |
void | wait () |
Waits on the condition. More... | |
void | wait (double timeout) |
Waits on the condition, with a timeout. More... | |
This class implements a condition variable; see ConditionVar for a brief introduction to this class.
The ConditionVarFull class provides a more complete implementation than ConditionVar; in particular, it provides the notify_all() method, which is guaranteed to wake up all threads currently waiting on the condition (whereas notify() is guaranteed to wake up at least one thread, but may or may not wake up all of them).
This class exists because on certain platforms (e.g. Win32), implementing notify_all() requires more overhead, so you should use ConditionVar for cases when you do not require the notify_all() semantics.
There are still some minor semantics that POSIX condition variables provide which this implementation does not. For instance, it is required (not optional) that the caller of notify() or notify_all() is holding the condition variable's mutex before the call.
This class inherits its implementation either from ConditionVarFullDebug or ConditionVarFullDirect, depending on the definition of DEBUG_THREADS.
Definition at line 44 of file conditionVarFull.h.
|
inlineexplicit |
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 21 of file conditionVarFull.I.
|
inline |
Returns the mutex associated with this condition variable.
Definition at line 34 of file conditionVarFull.I.
References ConditionVarFullDirect::get_mutex().