FRIBParallelanalysis  1.0
FrameworkforMPIParalleldataanalysisatFRIB
Public Member Functions | Public Attributes | List of all members
CConditionVariable Class Reference

#include <CTCLConditionVariable.h>

Public Member Functions

 CConditionVariable ()
 
 CConditionVariable (pthread_condattr_t &attr)
 
 CConditionVariable (CConditionAttributes &attr)
 
virtual ~CConditionVariable ()
 
void signal ()
 
void broadcast ()
 
bool timedwait (CMutex &mutex, const struct timespec *abstime)
 
bool timedwait (pthread_mutex_t *mutex, const struct timespec *abstime)
 
bool timedwait (CMutex &mutex, int milliseconds)
 
bool timedwait (pthread_mutex_t *mutex, int milliseconds)
 
void wait (CMutex &mutex)
 
void wait (pthread_mutex_t *mutex)
 

Public Attributes

pthread_cond_t m_condition
 

Detailed Description

Direct encapsulation of a pthread condition variable.

Constructor & Destructor Documentation

◆ CConditionVariable() [1/3]

CConditionVariable::CConditionVariable ( )

Construct a condition variable with default attributes:

◆ CConditionVariable() [2/3]

CConditionVariable::CConditionVariable ( pthread_condattr_t &  attr)

Construct a condition variable givena a reference to a raw attributes block

Parameters
attr- reference to a pthread_condattr_t.

◆ CConditionVariable() [3/3]

CConditionVariable::CConditionVariable ( CConditionAttributes attr)

Construct a condition variable given a reference to an encapsulated condition variable attribute block.

Parameters
attr- A CConditionAttributes reference.

◆ ~CConditionVariable()

CConditionVariable::~CConditionVariable ( )
virtual

Destructor destroys the condition variable. We will ignore the return status.

Member Function Documentation

◆ broadcast()

void CConditionVariable::broadcast ( )

Broadcast a condition variable. This unblocks all thread blocked on the condition variable. If the threads are using the same mutex, the scheduler will determine the order in which the threads gain access to the mutex. When the thread application code regains control, it will hold the mutex associated with the block.

◆ signal()

void CConditionVariable::signal ( )

Signal a condition variable unblocking one thread...the unblocked thread will come out of the block holding the mutex it associated with its wait.

◆ timedwait() [1/4]

bool CConditionVariable::timedwait ( CMutex mutex,
const struct timespec *  abstime 
)

Waits for a condition variable to be signalled.

  • Atomically releases the mutex passed in and
  • wait to be wakened by either a signal or broadcast operation for at most a timeout.
  • If action on the condition variable woke the blocked thread, the thread will own the mutex as well.
  • If the wait timedout, the thread will not own the mutex.
Parameters
mutex- The encapsulated mutex that will be atomically released when blocking. Note that all threads that cooperate on this condition variable should use the same mutex, but this is not enforeced.
abstime- Absolute time at which the condition variable should timeout.
Returns
bool
Return values
true- The thread woke up due to a signal/broadcast on the condition variable.
false-The thread timed out on the wait.
Exceptions
CErrnoException- if there was another error.

◆ timedwait() [2/4]

bool CConditionVariable::timedwait ( pthread_mutex_t *  mutex,
const struct timespec *  abstime 
)

Same as above but the mutex is a bare pthread mutex. This function actually is the one that does all the work. The overloads just map parameters and call us.

◆ timedwait() [3/4]

bool CConditionVariable::timedwait ( CMutex mutex,
int  milliseconds 
)

Same as above, however the timeout is expressed as milliseconds

◆ timedwait() [4/4]

bool CConditionVariable::timedwait ( pthread_mutex_t *  mutex,
int  milliseconds 
)

Same as above, but the mutex is a pthread mutex

◆ wait() [1/2]

void CConditionVariable::wait ( CMutex mutex)

Wait until the condition variable is signalled, or we are interrupted.

Parameters
mutex- The wrapped mutex we are holding that is associated with the condition variable. This should be the same for all callers of wait and timedwait.

◆ wait() [2/2]

void CConditionVariable::wait ( pthread_mutex_t *  mutex)

Same as above, but with a bare Pthread mutex.


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