libcommonc++  0.7
ConditionVar Class Reference

A condition variable – a synchronization mechanism used to coordinate the actions of multiple threads. More...

#include <ConditionVar.h++>

Public Member Functions

 ConditionVar ()
 Construct a new ConditionVar. More...
 
 ~ConditionVar ()
 Destructor. More...
 
bool wait (Mutex &mutex, uint_t msec=FOREVER)
 Wait for the condition variable to be signalled. More...
 
void notify ()
 Signal one of the threads that are waiting on this condition variable. More...
 
void notifyAll ()
 Signal all threads that are waiting on this condition variable. More...
 

Static Public Attributes

static const uint_t FOREVER = 0
 A constant representing an infinite wait. More...
 

Detailed Description

A condition variable – a synchronization mechanism used to coordinate the actions of multiple threads.

A condition variable is signalled to indicate that the state of some shared data has changed; one or more threads can wait on the condition variable for this change to occur.

Author
Mark Lindner

Constructor & Destructor Documentation

◆ ConditionVar()

Construct a new ConditionVar.

◆ ~ConditionVar()

Destructor.

Member Function Documentation

◆ notify()

void notify ( )

Signal one of the threads that are waiting on this condition variable.

If predictable scheduling behavior is required, the associated mutex should be held by the thread at the time that it calls this method.

◆ notifyAll()

void notifyAll ( )

Signal all threads that are waiting on this condition variable.

If predictable scheduling behavior is required, the associated mutex should be held by the thread at the time that it calls this method.

◆ wait()

bool wait ( Mutex mutex,
uint_t  msec = FOREVER 
)

Wait for the condition variable to be signalled.

The associated mutex should be held by the thread at the time that it calls this method.

Parameters
mutexThe mutex that is protecting the shared data; the mutex will be automatically released during the wait and reacquired when the wait completes.
msecThe amount of time to wait, or FOREVER to wait indefinitely.
Returns
true if the condition variable was signalled, false otherwise.

Member Data Documentation

◆ FOREVER

const uint_t FOREVER = 0
static

A constant representing an infinite wait.


The documentation for this class was generated from the following files: