Flair
Framework Libre Air
flair::core::ConditionVariable Class Reference

Class defining a condition variable. More...

#include <ConditionVariable.h>

+ Inheritance diagram for flair::core::ConditionVariable:

Public Member Functions

 ConditionVariable (const Object *parent, std::string name)
 Constructor. More...
 
 ~ConditionVariable ()
 Destructor. More...
 
void CondWait (void)
 Block on the condition variable. More...
 
bool CondWaitUntil (Time date)
 Block on the condition variable with a timeout. More...
 
void CondSignal (void)
 Unblock threads blocked on the condition variable. More...
 
- Public Member Functions inherited from flair::core::Mutex
 Mutex (const Object *parent, std::string name="")
 Constructor. More...
 
 ~Mutex ()
 Destructor. More...
 
void GetMutex (void) const
 GetMutex. More...
 
void ReleaseMutex (void) const
 ReleaseMutex. More...
 
- Public Member Functions inherited from flair::core::Object
 Object (const Object *parent=NULL, std::string name="", std::string type="")
 Constructor. More...
 
virtual ~Object ()
 Destructor. More...
 
std::string ObjectName (void) const
 Name. More...
 
std::string ObjectType (void) const
 Type. More...
 
const ObjectParent (void) const
 Parent. More...
 
std::vector< const Object * > * TypeChilds (void) const
 Childs of the same type. More...
 
std::vector< const Object * > * Childs (void) const
 Childs. More...
 
void Information (const char *function, int line, const char *format,...) const
 Formatted information. More...
 
void Warning (const char *function, const char *format,...) const
 Formatted warning. More...
 
void Error (const char *function, const char *format,...) const
 Formatted error. More...
 
bool ErrorOccured (bool recursive=true) const
 Has an errror occured? More...
 

Additional Inherited Members

- Public Types inherited from flair::core::Object
enum  color_t { Auto = 0, Red = 31, Green = 32, Orange = 33 }
 

Detailed Description

Class defining a condition variable.

Constructor & Destructor Documentation

flair::core::ConditionVariable::ConditionVariable ( const Object parent,
std::string  name 
)

Constructor.

Construct a condition variable with its associated mutex.

Parameters
parentparent
namename
flair::core::ConditionVariable::~ConditionVariable ( )

Destructor.

Member Function Documentation

void flair::core::ConditionVariable::CondWait ( void  )

Block on the condition variable.

This method must be called with mutex locked (see Mutex::GetMutex) by the calling thread or undefined behaviour will result.
It atomically releases mutex and causes the calling thread to block on the condition variable.
Only one thread can be blocked at the same time.
Upon successful return, the mutex has been locked and is owned by the calling thread which should unlock it (see Mutex::ReleaseMutex).

bool flair::core::ConditionVariable::CondWaitUntil ( Time  date)

Block on the condition variable with a timeout.

This method must be called with mutex locked (see Mutex::GetMutex) by the calling thread or undefined behaviour will result.
It atomically releases mutex and causes the calling thread to block on the condition variable.
Only one thread can be blocked at the same time.
Upon successful return, the mutex has been locked and is owned by the calling thread which should unlock it (see Mutex::ReleaseMutex).

Parameters
dateabsolute date
Returns
true if the condition variable is signaled before the date specified in parameter elapses, false otherwise
void flair::core::ConditionVariable::CondSignal ( void  )

Unblock threads blocked on the condition variable.

This method should be called with mutex locked (see Mutex::GetMutex) by the calling thread.
In this case, upon return, the calling thread should unlock the mutex (see Mutex::ReleaseMutex).