![]() |
Deskflow 1.24.0.365
Keyboard and mouse sharing utility
|
Generic condition variable. More...
#include <CondVar.h>

Public Member Functions | |
| CondVarBase (Mutex *mutex) | |
| ~CondVarBase () | |
manipulators | |
| void | lock () const |
| Lock the condition variable's mutex. | |
| void | unlock () const |
| Unlock the condition variable's mutex. | |
| void | signal () |
| Signal the condition variable. | |
| void | broadcast () |
| Signal the condition variable. | |
accessors | |
| bool | wait (double timeout=-1.0) const |
| Wait on the condition variable. | |
| bool | wait (Stopwatch &timer, double timeout) const |
| Wait on the condition variable. | |
| Mutex * | getMutex () const |
| Get the mutex. | |
Generic condition variable.
This class provides functionality common to all condition variables but doesn't provide the actual variable storage. A condition variable is a multiprocessing primitive that can be waited on. Every condition variable has an associated mutex.
|
explicit |
mutex must not be nullptr. All condition variables have an associated mutex. The mutex needn't be unique to one condition variable.
| CondVarBase::~CondVarBase | ( | ) |
| void CondVarBase::broadcast | ( | ) |
Signal the condition variable.
Wake up all waiting threads, if any.
| Mutex * CondVarBase::getMutex | ( | ) | const |
Get the mutex.
Get the mutex passed to the c'tor.
| void CondVarBase::lock | ( | ) | const |
| void CondVarBase::signal | ( | ) |
Signal the condition variable.
Wake up one waiting thread, if there are any. Which thread gets woken is undefined.
| void CondVarBase::unlock | ( | ) | const |
Unlock the condition variable's mutex.
| bool CondVarBase::wait | ( | double | timeout = -1.0 | ) | const |
Wait on the condition variable.
Wait on the condition variable. If timeout < 0 then wait until signalled, otherwise up to timeout seconds or until signalled, whichever comes first. Returns true if the object was signalled during the wait, false otherwise.
The proper way to wait for a condition is:
where cv-expr involves the value of cv and is false when the condition is satisfied.
(cancellation point)
| bool CondVarBase::wait | ( | Stopwatch & | timer, |
| double | timeout ) const |
Wait on the condition variable.
Same as wait(double) but use timer to compare against timeout. Since clients normally wait on condition variables in a loop, clients can use this to avoid recalculating timeout on each iteration. Passing a stopwatch with a negative timeout is pointless (it will never time out) but permitted.
(cancellation point)