fesa-core  4.3.1
fesa::ConditionalVariable Class Reference

This class is a c++ wrapper in order to use conditional variables. Conditional variables help to synchronize threads when there's a logical condition for the synchronization. More...

#include <ConditionalVariable.h>

Inheritance diagram for fesa::ConditionalVariable:
fesa::SharedConditionalVariable

Public Member Functions

 ConditionalVariable ()
 constructor

Exceptions
FesaException

 
 ~ConditionalVariable ()
 destructor
 
void signal ()
 This method sends a signal to the conditional variable telling it that the thread can continue

Exceptions
FesaException.

 
void signalAll ()
 
void wait (const Mutex &mutex) const
 This method waits until a signal arrives stopping the thread. The mutex passed by argument has to be locked before invoking this method. More...
 
bool wait (const Mutex &mutex, std::time_t timeoutSec, std::time_t timeoutNanoSec) const
 This method waits until a signal arrives or the timeout was hit. The mutex passed by argument has to be locked before invoking this method. More...
 

Protected Member Functions

 ConditionalVariable (bool initialize)
 

Protected Attributes

pthread_cond_t condition_
 internal condition representation
 

Detailed Description

This class is a c++ wrapper in order to use conditional variables. Conditional variables help to synchronize threads when there's a logical condition for the synchronization.

Constructor & Destructor Documentation

fesa::ConditionalVariable::ConditionalVariable ( bool  initialize)
protected

Constructor which can skip initialization of condition_.

Parameters
initializethe condition variable is initialized only if this is true.

Member Function Documentation

void fesa::ConditionalVariable::signalAll ( )

Signal all the threads waiting on this condition variable.

void fesa::ConditionalVariable::wait ( const Mutex mutex) const

This method waits until a signal arrives stopping the thread. The mutex passed by argument has to be locked before invoking this method.

Parameters
mutexto lock
bool fesa::ConditionalVariable::wait ( const Mutex mutex,
std::time_t  timeoutSec,
std::time_t  timeoutNanoSec 
) const

This method waits until a signal arrives or the timeout was hit. The mutex passed by argument has to be locked before invoking this method.

Parameters
mutexto lock
timeoutSec- full seconds
timeoutSec- timeoutNanoSec
Returns
true if timed out

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