OpenWalnut  1.5.0dev
Public Types | Public Member Functions | Protected Types | Protected Attributes | Friends | List of all members
WCondition Class Reference

Class to encapsulate boost::condition_variable_any. More...

#include <WCondition.h>

+ Inheritance diagram for WCondition:
+ Collaboration diagram for WCondition:

Public Types

typedef std::shared_ptr< WConditionSPtr
 Shared pointer type for WCondition. More...
 
typedef std::shared_ptr< const WConditionConstSPtr
 Const shared pointer type for WCondition. More...
 
typedef boost::function0< void > t_ConditionNotifierType
 Type used for signalling condition changes. More...
 

Public Member Functions

 WCondition ()
 Default constructor. More...
 
virtual ~WCondition ()
 Destructor. More...
 
virtual void wait () const
 Wait for the condition. More...
 
virtual void notify ()
 Notifies all waiting threads. More...
 
boost::signals2::connection subscribeSignal (t_ConditionNotifierType notifier) const
 Subscribes a specified function to be notified on condition change. More...
 

Protected Types

typedef boost::signals2::signal< void(void)> t_ConditionSignalType
 Type used for condition notification. More...
 

Protected Attributes

t_ConditionSignalType signal_ConditionFired
 Signal getting fired whenever the condition fires. More...
 
boost::condition_variable_any m_condition
 The condition. More...
 
std::shared_mutex m_mutex
 The mutex used for the condition. More...
 

Friends

class WCondition_test
 Access for test class. More...
 

Detailed Description

Class to encapsulate boost::condition_variable_any.

You may use it to efficiently wait for events (a condition comes true). It is a very simple implementation. It can be extended easily, e.g. to timed wait functions and so on.

Definition at line 41 of file WCondition.h.

Member Typedef Documentation

◆ ConstSPtr

typedef std::shared_ptr< const WCondition > WCondition::ConstSPtr

Const shared pointer type for WCondition.

Definition at line 53 of file WCondition.h.

◆ SPtr

typedef std::shared_ptr< WCondition > WCondition::SPtr

Shared pointer type for WCondition.

Definition at line 48 of file WCondition.h.

◆ t_ConditionNotifierType

typedef boost::function0< void > WCondition::t_ConditionNotifierType

Type used for signalling condition changes.

Definition at line 78 of file WCondition.h.

◆ t_ConditionSignalType

typedef boost::signals2::signal<void ( void )> WCondition::t_ConditionSignalType
protected

Type used for condition notification.

Definition at line 93 of file WCondition.h.

Constructor & Destructor Documentation

◆ WCondition()

WCondition::WCondition ( )

Default constructor.

Definition at line 27 of file WCondition.cpp.

◆ ~WCondition()

WCondition::~WCondition ( )
virtual

Destructor.

Definition at line 32 of file WCondition.cpp.

Member Function Documentation

◆ notify()

void WCondition::notify ( )
virtual

◆ subscribeSignal()

boost::signals2::connection WCondition::subscribeSignal ( t_ConditionNotifierType  notifier) const

Subscribes a specified function to be notified on condition change.

Parameters
notifierthe notifier function
Returns
the connection.

Definition at line 50 of file WCondition.cpp.

References signal_ConditionFired.

Referenced by WGraphicsEngine::subscribeSignal(), WKernel::subscribeSignal(), and WFlagTest::testChangeCondition().

+ Here is the caller graph for this function:

◆ wait()

void WCondition::wait ( ) const
virtual

Wait for the condition.

Sets the calling thread asleep.

Reimplemented in WConditionSet, and WConditionOneShot.

Definition at line 37 of file WCondition.cpp.

References m_condition, and m_mutex.

Referenced by WConditionTest::testWaitNotify(), and WConditionSet::wait().

+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ WCondition_test

friend class WCondition_test
friend

Access for test class.

Definition at line 43 of file WCondition.h.

Member Data Documentation

◆ m_condition

boost::condition_variable_any WCondition::m_condition
mutableprotected

The condition.

Definition at line 103 of file WCondition.h.

Referenced by notify(), wait(), and WConditionOneShot::wait().

◆ m_mutex

std::shared_mutex WCondition::m_mutex
mutableprotected

The mutex used for the condition.

Definition at line 108 of file WCondition.h.

Referenced by wait(), and WConditionOneShot::wait().

◆ signal_ConditionFired

t_ConditionSignalType WCondition::signal_ConditionFired
mutableprotected

Signal getting fired whenever the condition fires.

Definition at line 98 of file WCondition.h.

Referenced by notify(), and subscribeSignal().


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