#include <CAVERNts_condition_c.hxx>
Public Methods | |
int | wait (CAVERNts_mutex_c *mutex) |
int | signal () |
int | broadcastSignal () |
CAVERN_COND_T* | getCondition () |
Return condition variable. | |
CAVERNts_condition_c () | |
~CAVERNts_condition_c () | |
Private Attributes | |
CAVERN_COND_T | itsCV |
An example of waiting on a signal is:
\begin{verbatim}
Lock your mutex that is protecting someState. myMutex->lock();
Watch for your desired state to occur. while(someState != reached) {
Wait for a signal. myCondition->wait(myMutex);
.... got the condition and the lock so now continue ....
}
myMutex->unlock();
\end{verbatim}
An example of sending the signal is:
\begin{verbatim}
Lock your mutex that is protecting someState. myMutex->lock();
Signal that the state has been reached. if (someState == reached) myCondition->signal();
Unlock your mutex so that the waiting thread can continue. myMutex->unlock();
\end{verbatim}
|
Signal that a condition has arisen. This wakes up ALL threads that are suspended on this condition. If no threads are suspended this call has no effect.
|
|
Signal that a condition has arisen. This wakes up one thread that is suspended on this condition. If no threads are suspended this call has no effect.
|
|
Wait on a condition to be signalled. This function first releases the mutex and then waits on the condition. When the condition arises (ie it has been signaled) the mutex is reaquired, and the function returns.
|