ASL
|
A condition variable allows one or more threads to wait until a condition is made true by another thread.
The condition or watched resource itself must be protected by a mutex and this mutex given to the condition variable. This is how this is done:
We have the ready flag to wait until it is true:
One thread waits for it to become true like this:
Another thread, when it is ready signals it like this:
#include <Mutex.h>
Public Member Functions | |
Condition (Mutex &m) | |
Constructs a condition variable with a mutex to use. | |
void | use (Mutex &m) |
Sets mutex to use if it was not given in the constructor. | |
void | signal () |
Wake up waiting threads to signal a condition change. | |
void | wait () |
Wait for the condition change to be signaled. | |
bool | wait (double timeout) |
Wait for the condition change to be signaled up to a timeout and return true if there was no signal. | |