Lunchbox
1.15.0
Multi-threaded C++ toolbox library for all application developers creating high-performance multi-threaded programs.
|
A condition variable and associated lock. More...
#include <condition.h>
Public Member Functions | |
Condition () | |
Construct a new condition variable. More... | |
~Condition () | |
Destruct this condition variable. More... | |
void | lock () |
Lock the mutex. More... | |
void | unlock () |
Unlock the mutex. More... | |
void | signal () |
Signal the condition. More... | |
void | broadcast () |
Broadcast the condition. More... | |
void | wait () |
Atomically unlock the mutex, wait for a signal and relock the mutex. More... | |
bool | timedWait (const uint32_t timeout) |
Atomically unlock the mutex, wait for a signal and relock the mutex. More... | |
A condition variable and associated lock.
Semantics follow closely pthread_condition and mutex.
Definition at line 33 of file condition.h.
lunchbox::Condition::Condition | ( | ) |
Construct a new condition variable.
lunchbox::Condition::~Condition | ( | ) |
Destruct this condition variable.
void lunchbox::Condition::broadcast | ( | ) |
Broadcast the condition.
Referenced by lunchbox::Monitor< T >::operator&=(), lunchbox::Monitor< T >::operator++(), lunchbox::Monitor< T >::operator--(), lunchbox::operator<<(), lunchbox::Monitor< T >::operator|=(), lunchbox::MTQueue< T, S >::popBarrier(), and lunchbox::Monitor< T >::set().
void lunchbox::Condition::lock | ( | ) |
Lock the mutex.
Referenced by lunchbox::MTQueue< T, S >::getBack(), lunchbox::MTQueue< T, S >::getFront(), lunchbox::MTQueue< T, S >::operator=(), lunchbox::MTQueue< T, S >::popBarrier(), lunchbox::MTQueue< T, S >::push(), and lunchbox::MTQueue< T, S >::pushFront().
void lunchbox::Condition::signal | ( | ) |
Signal the condition.
Referenced by lunchbox::MTQueue< T, S >::popBarrier(), lunchbox::MTQueue< T, S >::push(), and lunchbox::MTQueue< T, S >::pushFront().
bool lunchbox::Condition::timedWait | ( | const uint32_t | timeout | ) |
Atomically unlock the mutex, wait for a signal and relock the mutex.
The operation is aborted after the given timeout and false is returned.
timeout | the timeout in milliseconds to wait for the signal. |
Referenced by lunchbox::Monitor< T >::operator&().
void lunchbox::Condition::unlock | ( | ) |
Unlock the mutex.
Referenced by lunchbox::MTQueue< T, S >::getBack(), lunchbox::MTQueue< T, S >::getFront(), lunchbox::MTQueue< T, S >::operator=(), lunchbox::MTQueue< T, S >::popBarrier(), lunchbox::MTQueue< T, S >::push(), and lunchbox::MTQueue< T, S >::pushFront().
void lunchbox::Condition::wait | ( | ) |
Atomically unlock the mutex, wait for a signal and relock the mutex.
Referenced by lunchbox::Monitor< T >::operator&(), lunchbox::MTQueue< T, S >::popBarrier(), lunchbox::MTQueue< T, S >::push(), lunchbox::MTQueue< T, S >::pushFront(), and lunchbox::Monitor< T >::waitNE().