A condition variable. More...
#include <libppbase/base/Condition.h>
Public Member Functions | |
Condition (Mutex *mutex=NULL, bool own=false) | |
Constructor. | |
~Condition () | |
Destructor. | |
void | lock () |
Locks the associated mutex. | |
void | signal (bool broadcast=false) |
Signals the condition. | |
void | unlock () |
Unlocks the associated mutex. | |
bool | wait (int timeout=0, bool dolock=false) |
Waits for the condition. | |
Protected Member Functions | |
DISALLOW_COPY_CONSTRUCTOR_AND_ASSIGNMENT (Condition) | |
condition objects may not be duplicated | |
Protected Attributes | |
pthread_cond_t | _cond |
the pthread condition variable | |
Mutex * | _mutex |
associated mutex | |
bool | _own |
flag: owns mutex |
A condition variable.
void base::Condition::signal | ( | bool | broadcast = false |
) |
Signals the condition.
broadcast | flag: wake up all threads waiting on this condition |
Referenced by base::WorkPile< Socket * >::dequeue(), and base::WorkPile< Socket * >::enqueue().
bool base::Condition::wait | ( | int | timeout = 0 , |
|
bool | dolock = false | |||
) |
Waits for the condition.
timeout | timeout in seconds, <=0 means infinite | |
dolock | flag: lock the mutex |
Referenced by base::WorkPile< Socket * >::dequeue(), and base::WorkPile< Socket * >::enqueue().