OpenWalnut
1.5.0dev
|
Implements a WCondition, but can be fired only ONCE. More...
#include <WConditionOneShot.h>
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< WCondition > | SPtr |
Shared pointer type for WCondition. More... | |
typedef std::shared_ptr< const WCondition > | ConstSPtr |
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... | |
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.
WConditionOneShot::WConditionOneShot | ( | ) |
|
virtual |
Destructor.
Definition at line 34 of file WConditionOneShot.cpp.
|
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().
|
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().
|
friend |
Access for test class.
Definition at line 43 of file WConditionOneShot.h.
|
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().