The Micro C++ Library
|
A Condition provides yet another way for threads to synchronize based upon the actual value of data. More...
#include <micxx.hxx>
Inherits micxx::Mutex.
Inherited by micxx::PCQueue< T >, and micxx::Semaphore [protected]
.
Public Member Functions | |
Condition () | |
Create a new Condition. | |
virtual | ~Condition () |
Deallocate and release the internally allocated condition resources. | |
virtual bool | wait (unsigned long timeoutMillis=0) |
Blocks the calling thread until it is signaled from any other thread by notifyAll(). | |
virtual void | notifyAll () |
Signals all waiting threads that the Condition is met. |
A Condition provides yet another way for threads to synchronize based upon the actual value of data.
"Without condition variables, the programmer would need to have threads continually polling (possibly in a critical section), to check if the condition is met. This can be very resource consuming since the thread would be continuously busy in this activity. A condition variable is a way to achieve the same goal without polling."
A condition variable must always be used in conjunction with a mutex lock.
micxx::Condition::Condition | ( | ) |
Create a new Condition.
virtual micxx::Condition::~Condition | ( | ) | [virtual] |
Deallocate and release the internally allocated condition resources.
virtual void micxx::Condition::notifyAll | ( | ) | [virtual] |
Signals all waiting threads that the Condition is met.
All threads waiting for this Condition to be met continue its execution, competing for the lock of the underlying mutex again in order to return from wait().
virtual bool micxx::Condition::wait | ( | unsigned long | timeoutMillis = 0 | ) | [virtual] |
Blocks the calling thread until it is signaled from any other thread by notifyAll().
As long as wait() does not return any other thread may be able to obtain the lock of the underlying mutex.
timeoutMillis | The number of milli seconds to wait until the call returns without being signaled by notifyAll(). If 0 , the call will wait indefinitely long. |