cxxtools::Condition Class Reference

This class is used to control concurrent access. More...

#include <cxxtools/condition.h>

Inheritance diagram for cxxtools::Condition:
cxxtools::NonCopyable

Public Member Functions

 Condition ()
 Default Constructor.
 ~Condition ()
 Destructor.
void wait (Mutex &mtx)
 Wait until condition becomes signalled.
void wait (MutexLock &m)
bool wait (Mutex &mtx, unsigned int ms)
 Wait until condition becomes signalled.
bool wait (MutexLock &m, unsigned int ms)
void signal ()
 Unblock a single blocked thread.
void broadcast ()
 Unblock all blocked threads.

Additional Inherited Members

- Private Member Functions inherited from cxxtools::NonCopyable
 NonCopyable ()

Detailed Description

This class is used to control concurrent access.

The Condition class is used to control concurrent access in a queued manner. The Condition class supports two types of signaling events, manual reset and automatic reset. Manual resets cause all blocked callers to be released. This can be understood as some kind of broadcast to signal all blocked callers at once. Manual resets are triggered by a call to signal(). Automatic resets cause only a single blocked caller to be released. So this can be seen as some kind of wait queue where only the topmost is signaled. Automatic resets are signaled by a call to broadcast().

Constructor & Destructor Documentation

cxxtools::Condition::Condition ( )

Default Constructor.

cxxtools::Condition::~Condition ( )

Destructor.

Member Function Documentation

void cxxtools::Condition::broadcast ( )

Unblock all blocked threads.

void cxxtools::Condition::signal ( )

Unblock a single blocked thread.

void cxxtools::Condition::wait ( Mutex mtx)

Wait until condition becomes signalled.

Causes the caller to be suspended until the condition will be signaled. The given mutex will be unlocked before the caller is suspended.

void cxxtools::Condition::wait ( MutexLock m)
inline
bool cxxtools::Condition::wait ( Mutex mtx,
unsigned int  ms 
)

Wait until condition becomes signalled.

Causes the caller to be suspended until the condition will be signaled. The given mutex will be unlocked before the caller is suspended. The suspension takes at maximum ms milliseconds. Returns true if successful, false if a timeout occurred.

bool cxxtools::Condition::wait ( MutexLock m,
unsigned int  ms 
)
inline

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