Miosix  2.0alpha1
miosix::ConditionVariable Class Reference

#include <sync.h>

Public Member Functions

 ConditionVariable ()
 
template<typename T >
void wait (Lock< T > &l)
 
void wait (Mutex &m)
 
void wait (FastMutex &m)
 
void signal ()
 
void broadcast ()
 

Detailed Description

A condition variable class for thread synchronization, available from Miosix 1.53.
One or more threads can wait on the condition variable, and the signal() and broadcast() allow to wake ne or all the waiting threads.
This class is meant to be a static or global class. Dynamically creating a ConditionVariable with new or on the stack must be done with care, to avoid deleting a ConditionVariable while some threads are waiting, and to avoid situations where a thread tries to wait on a deleted ConditionVariable.

Constructor & Destructor Documentation

miosix::ConditionVariable::ConditionVariable ( )

Constructor, initializes the ConditionVariable.

Member Function Documentation

void miosix::ConditionVariable::broadcast ( )

Wakeup all waiting threads.

void miosix::ConditionVariable::signal ( )

Wakeup one waiting thread. Currently implemented policy is fifo.

template<typename T >
void miosix::ConditionVariable::wait ( Lock< T > &  l)
inline

Unlock the mutex and wait. If more threads call wait() they must do so specifying the same mutex, otherwise the behaviour is undefined.

Parameters
lA Lock instance that locked a Mutex
void miosix::ConditionVariable::wait ( Mutex m)

Unlock the Mutex and wait. If more threads call wait() they must do so specifying the same mutex, otherwise the behaviour is undefined.

Parameters
ma locked Mutex
void miosix::ConditionVariable::wait ( FastMutex m)

Unlock the FastMutex and wait. If more threads call wait() they must do so specifying the same mutex, otherwise the behaviour is undefined.

Parameters
ma locked Mutex

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