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

Implements a WCondition, but can be fired only ONCE. More...

#include <WConditionOneShot.h>

+ Inheritance diagram for WConditionOneShot:
+ Collaboration diagram for WConditionOneShot:

Public Member Functions

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

Protected Attributes

std::atomic< bool > m_isDone
 Atomic bool whether this conditon has been done or not. More...
 
- Protected Attributes inherited from WCondition
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 WConditionOneShot_test
 Access for test class. More...
 

Additional Inherited Members

- Public Types inherited from WCondition
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...
 
- Protected Types inherited from WCondition
typedef boost::signals2::signal< void(void)> t_ConditionSignalType
 Type used for condition notification. More...
 

Detailed Description

Implements a WCondition, but can be fired only ONCE.

This is useful if you want to have a thread waiting for a condition but you can not assure that the thread already waits when you set the condition. This would cause the thread to wait endlessly because it does not know that you already fired it.

Definition at line 41 of file WConditionOneShot.h.

Constructor & Destructor Documentation

◆ WConditionOneShot()

WConditionOneShot::WConditionOneShot ( )

Default constructor.

Definition at line 27 of file WConditionOneShot.cpp.

References m_isDone.

◆ ~WConditionOneShot()

WConditionOneShot::~WConditionOneShot ( )
virtual

Destructor.

Definition at line 34 of file WConditionOneShot.cpp.

Member Function Documentation

◆ notify()

void WConditionOneShot::notify ( )
virtual

Notifies all waiting threads.

Reimplemented from WCondition.

Definition at line 51 of file WConditionOneShot.cpp.

References m_isDone, and WCondition::notify().

Referenced by WGraphicsEngine::finalizeStartup(), WGraphicsEngine::notifyStop(), WConditionOneShotTest::testWaitNotify(), CallableHelper::threadMain(), and WKernel::threadMain().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ wait()

void WConditionOneShot::wait ( ) const
virtual

Wait for the condition.

Sets the calling thread asleep.

Reimplemented from WCondition.

Definition at line 39 of file WConditionOneShot.cpp.

References WCondition::m_condition, m_isDone, and WCondition::m_mutex.

Referenced by WConditionOneShotTest::testWaitNotify(), and WGraphicsEngine::waitForFinalize().

+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ WConditionOneShot_test

friend class WConditionOneShot_test
friend

Access for test class.

Definition at line 43 of file WConditionOneShot.h.

Member Data Documentation

◆ m_isDone

std::atomic< bool > WConditionOneShot::m_isDone
protected

Atomic bool whether this conditon has been done or not.

Definition at line 69 of file WConditionOneShot.h.

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


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