BLOCXX_NAMESPACE::Condition Class Reference

The Condition class represents a synchronization device that allows threads to suspend execution and relinquish the processors until another thread signals the condition. More...

#include <Condition.hpp>

List of all members.

Public Member Functions

 Condition ()
 Construct a new Condition object.
 ~Condition ()
 Destroy this Condition object.
void notifyOne ()
 Signal one thread that is currently waiting on the Condition object through the wait or timedWait methods.
void notifyAll ()
 Signal all threads that are currently waiting on the Condition object.
void wait (NonRecursiveMutexLock &lock)
 Atomically unlock a given mutex and wait for the this Condition object to get signalled.
bool timedWait (NonRecursiveMutexLock &lock, UInt32 sTimeout, UInt32 usTimeout=0)
 Atomically unlock a given mutex and wait for a given amount of time for this Condition object to get signalled.

Private Member Functions

 Condition (const Condition &)
Conditionoperator= (const Condition &)
void doWait (NonRecursiveMutex &mutex)
bool doTimedWait (NonRecursiveMutex &mutex, UInt32 sTimeout, UInt32 usTimeout)

Private Attributes

ConditionVar_t m_condition


Detailed Description

The Condition class represents a synchronization device that allows threads to suspend execution and relinquish the processors until another thread signals the condition.

The thread that signals the Condition object has the option of only letting one waiting thread receive the notification, or all threads.

Definition at line 58 of file Condition.hpp.


Constructor & Destructor Documentation

BLOCXX_NAMESPACE::Condition::Condition  ) 
 

Construct a new Condition object.

Definition at line 54 of file Condition.cpp.

References BLOCXX_THROW, and m_condition.

BLOCXX_NAMESPACE::Condition::~Condition  ) 
 

Destroy this Condition object.

Definition at line 63 of file Condition.cpp.

References m_condition.

BLOCXX_NAMESPACE::Condition::Condition const Condition  )  [private]
 


Member Function Documentation

bool BLOCXX_NAMESPACE::Condition::doTimedWait NonRecursiveMutex mutex,
UInt32  sTimeout,
UInt32  usTimeout
[private]
 

Definition at line 95 of file Condition.cpp.

References BLOCXX_NAMESPACE::NonRecursiveMutex::conditionPostWait(), BLOCXX_NAMESPACE::NonRecursiveMutex::conditionPreWait(), ETIMEDOUT, m_condition, and state.

void BLOCXX_NAMESPACE::Condition::doWait NonRecursiveMutex mutex  )  [private]
 

Definition at line 84 of file Condition.cpp.

References BLOCXX_NAMESPACE::NonRecursiveMutex::conditionPostWait(), BLOCXX_NAMESPACE::NonRecursiveMutex::conditionPreWait(), m_condition, and state.

void BLOCXX_NAMESPACE::Condition::notifyAll  ) 
 

Signal all threads that are currently waiting on the Condition object.

This will cause all threads waiting on a call to 'wait' or timedWait to stop blocking and continue execution.

Definition at line 77 of file Condition.cpp.

References m_condition.

Referenced by BLOCXX_NAMESPACE::ThreadCounter::decThreadCount(), BLOCXX_NAMESPACE::Thread::doneRunning(), BLOCXX_NAMESPACE::RWLocker::doWakeups(), BLOCXX_NAMESPACE::ThreadCounter::setMax(), and BLOCXX_NAMESPACE::Semaphore::signal().

void BLOCXX_NAMESPACE::Condition::notifyOne  ) 
 

Signal one thread that is currently waiting on the Condition object through the wait or timedWait methods.

All other threads waiting on this object through wait or timedWait will continue to block.

Definition at line 70 of file Condition.cpp.

References m_condition.

Referenced by BLOCXX_NAMESPACE::RWLocker::doWakeups().

Condition& BLOCXX_NAMESPACE::Condition::operator= const Condition  )  [private]
 

bool BLOCXX_NAMESPACE::Condition::timedWait NonRecursiveMutexLock lock,
UInt32  sTimeout,
UInt32  usTimeout = 0
 

Atomically unlock a given mutex and wait for a given amount of time for this Condition object to get signalled.

The thread execution is suspended and does not consume any CPU time until the Condition object is notified (signalled). The mutex lock must be locked by the calling thread on entrance to wait. Before returning to the calling thread, wait re-acquires the mutex lock. This function should always be called within a while loop that checks the condition.

Parameters:
lock The mutex lock object that must be acquired before calling this method.
sTimeout The number of seconds to wait for this Condition to get signalled.
usTimeout The number of micro seconds (1/1000000th) to wait for this Condition to get signalled. The total wait time is sTimeout * 1000000 + usTimeout micro seconds. This function should always be called within a while loop that checks the condition.
Returns:
true if the lock was acquired, false if timeout occurred.

Definition at line 261 of file Condition.cpp.

References BLOCXX_THROW, and BLOCXX_NAMESPACE::NonRecursiveMutexLock::isLocked().

Referenced by BLOCXX_NAMESPACE::Thread::definitiveCancel(), BLOCXX_NAMESPACE::RWLocker::getReadLock(), BLOCXX_NAMESPACE::ThreadCounter::incThreadCount(), BLOCXX_NAMESPACE::Semaphore::timedWait(), and BLOCXX_NAMESPACE::ThreadCounter::waitForAll().

void BLOCXX_NAMESPACE::Condition::wait NonRecursiveMutexLock lock  ) 
 

Atomically unlock a given mutex and wait for the this Condition object to get signalled.

The thread execution is suspended and does not consume any CPU time until the Condition object is notified (signalled). The mutex lock must be locked by the calling thread on entrance to wait. Before returning to the calling thread, wait re-acquires the mutex lock. This function should always be called within a while loop that checks the condition.

Parameters:
lock The mutex lock object that must be acquired before calling this method.

Definition at line 251 of file Condition.cpp.

References BLOCXX_THROW, and BLOCXX_NAMESPACE::NonRecursiveMutexLock::isLocked().

Referenced by BLOCXX_NAMESPACE::Semaphore::wait().


Member Data Documentation

ConditionVar_t BLOCXX_NAMESPACE::Condition::m_condition [private]
 

Definition at line 126 of file Condition.hpp.

Referenced by Condition(), doTimedWait(), doWait(), notifyAll(), notifyOne(), and ~Condition().


The documentation for this class was generated from the following files:
Generated on Fri Jun 16 15:39:10 2006 for blocxx by  doxygen 1.4.6