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

Class allowing multiple conditions to be used for one waiting cycle. More...

#include <WConditionSet.h>

+ Inheritance diagram for WConditionSet:
+ Collaboration diagram for WConditionSet:

Public Types

typedef std::shared_ptr< WConditionSetSPtr
 Shared pointer to instance of this class. More...
 
typedef std::shared_ptr< const WConditionSetConstSPtr
 Shared pointer to const instance of this class. More...
 
- 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...
 

Public Member Functions

 WConditionSet ()
 Default constructor. More...
 
virtual ~WConditionSet ()
 Destructor. More...
 
virtual void add (std::shared_ptr< WCondition > condition)
 Adds another condition to the set of conditions to wait for. More...
 
virtual void remove (std::shared_ptr< WCondition > condition)
 Removes the specified condition. More...
 
virtual void wait () const
 Wait for the condition. More...
 
virtual void reset () const
 Resets the internal fire state. More...
 
void setResetable (bool resetable=true, bool autoReset=true)
 Sets the resetable flag. More...
 
bool isResetable ()
 Returns whether the condition set acts like a one shot 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 Types

typedef std::map< std::shared_ptr< WCondition >, boost::signals2::connection > ConditionConnectionMap
 We need to keep track of the connections a condition has made since boost::function objects do not provide a == operator and can therefore not easily be removed from a signals by signal.desconnect( functor ). More...
 
typedef std::pair< std::shared_ptr< WCondition >, boost::signals2::connection > ConditionConnectionPair
 Each condition has a connection. More...
 
- Protected Types inherited from WCondition
typedef boost::signals2::signal< void(void)> t_ConditionSignalType
 Type used for condition notification. More...
 

Protected Member Functions

virtual void conditionFired ()
 Notifier function getting notified whenever a condition got fired. More...
 

Protected Attributes

bool m_resetable
 Flag denoting whether the condition set should act like a one shot condition. More...
 
bool m_autoReset
 Flag which shows whether the wait() call should reset the state m_fired when it returns. More...
 
ConditionConnectionMap m_conditionSet
 Set of conditions to be waited for. More...
 
std::shared_mutex m_conditionSetLock
 Lock used for thread-safe writing to the condition set. More...
 
bool m_fired
 Flag denoting whether one condition fired in the past. More...
 
WCondition::t_ConditionNotifierType m_notifier
 The notifier which gets called by all conditions if they fire. 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 WConditionSetTest
 Access for test class. More...
 

Detailed Description

Class allowing multiple conditions to be used for one waiting cycle.

Since wait() can not be used for waiting on multiple conditions, this class can encapsulate multiple conditions and offer a wait() command to wait for one of them to change its state. Please not that this class can also be used as condition.

Definition at line 43 of file WConditionSet.h.

Member Typedef Documentation

◆ ConditionConnectionMap

typedef std::map< std::shared_ptr< WCondition >, boost::signals2::connection > WConditionSet::ConditionConnectionMap
protected

We need to keep track of the connections a condition has made since boost::function objects do not provide a == operator and can therefore not easily be removed from a signals by signal.desconnect( functor ).

Definition at line 133 of file WConditionSet.h.

◆ ConditionConnectionPair

typedef std::pair< std::shared_ptr< WCondition >, boost::signals2::connection > WConditionSet::ConditionConnectionPair
protected

Each condition has a connection.

Definition at line 143 of file WConditionSet.h.

◆ ConstSPtr

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

Shared pointer to const instance of this class.

Definition at line 55 of file WConditionSet.h.

◆ SPtr

typedef std::shared_ptr< WConditionSet > WConditionSet::SPtr

Shared pointer to instance of this class.

Definition at line 50 of file WConditionSet.h.

Constructor & Destructor Documentation

◆ WConditionSet()

WConditionSet::WConditionSet ( )

Default constructor.

Definition at line 29 of file WConditionSet.cpp.

◆ ~WConditionSet()

WConditionSet::~WConditionSet ( )
virtual

Destructor.

Definition at line 38 of file WConditionSet.cpp.

References m_conditionSet, and m_conditionSetLock.

Member Function Documentation

◆ add()

void WConditionSet::add ( std::shared_ptr< WCondition condition)
virtual

Adds another condition to the set of conditions to wait for.

Note that, whenever someone is waiting for this WConditionSet, the newly added one is also directly included into the wait() call.

Parameters
conditionthe condition to add.

Definition at line 54 of file WConditionSet.cpp.

References m_conditionSet, m_conditionSetLock, and m_notifier.

Referenced by WMAnisotropicFiltering::moduleMain(), WMApplyMask::moduleMain(), WMArbitraryPlane::moduleMain(), WMArbitraryROIs::moduleMain(), WMButterfly::moduleMain(), WMCalculateGFA::moduleMain(), WMCalculateHistogram::moduleMain(), WMCalculateTensors::moduleMain(), WMClusterDisplay::moduleMain(), WMClusterDisplayVoxels::moduleMain(), WMColormapper::moduleMain(), WMCoordinateSystem::moduleMain(), WMData::moduleMain(), WMReadSphericalHarmonics::moduleMain(), WMWriteNIfTI::moduleMain(), WMDataCreatorFibers::moduleMain(), WMDataCreatorPoints::moduleMain(), WMDataCreatorScalar::moduleMain(), WMDataCreatorVector::moduleMain(), WMDatasetManipulator::moduleMain(), WMDatasetProfile::moduleMain(), WMDataTypeConversion::moduleMain(), WMDeterministicFTMori::moduleMain(), WMDiffTensorScalars::moduleMain(), WMDirectVolumeRendering::moduleMain(), WMDistanceMap::moduleMain(), WMEEGView::moduleMain(), WMEffectiveConnectivityCluster::moduleMain(), WMEigenSystem::moduleMain(), WMFiberDisplay::moduleMain(), WMFiberFilterIndex::moduleMain(), WMFiberFilterROI::moduleMain(), WMFiberParameterColoring::moduleMain(), WMFiberResampling::moduleMain(), WMFiberSelection::moduleMain(), WMFibersToPoints::moduleMain(), WMFiberTransform::moduleMain(), WMFiberTranslator::moduleMain(), WMFilterProtonData::moduleMain(), WMFunctionalMRIViewer::moduleMain(), WMGaussFiltering::moduleMain(), WMGridRenderer::moduleMain(), WMHARDIToSphericalHarmonics::moduleMain(), WMHierchClustDisplay::moduleMain(), WMPartition2Mesh::moduleMain(), WMHistogramEqualization::moduleMain(), WMHistogramView::moduleMain(), WMMultiHistogramView::moduleMain(), WMImageExtractor::moduleMain(), WMImageSpaceLIC::moduleMain(), WMImageSpaceTensorLIC::moduleMain(), WMIsosurface::moduleMain(), WMIsosurfaceRaytracer::moduleMain(), WMMergeComponentsToVector::moduleMain(), WMMergePoints::moduleMain(), WMMeshToPoints::moduleMain(), WMNavigationSlices::moduleMain(), WMOpenIGTLinkSender::moduleMain(), WMPaintTexture::moduleMain(), WMPickingDVR::moduleMain(), WMPickingDVREvaluation::moduleMain(), WMPointConnector::moduleMain(), WMPointRenderer::moduleMain(), WMProbTractDisplay::moduleMain(), WMProjectionsAsContext::moduleMain(), WMReadAmiraMesh::moduleMain(), WMReadDipoles::moduleMain(), WMReadMesh::moduleMain(), WMReadRawData::moduleMain(), WMReadVCL::moduleMain(), WMResampleRegular::moduleMain(), WMSampleOnFibers::moduleMain(), WMScalarOperator::moduleMain(), WMScalarSegmentation::moduleMain(), WMSpatialDerivative::moduleMain(), WMSplineSurface::moduleMain(), WMSuperquadricGlyphs::moduleMain(), WMSurfaceIllustrator::moduleMain(), WMSurfaceParameterAnimator::moduleMain(), WMTeemGlyphs::moduleMain(), WMTemplate::moduleMain(), WMTemplateColormapping::moduleMain(), WMTemplateRenderPipelines::moduleMain(), WMTemplateShaders::moduleMain(), WMTemplateUI::moduleMain(), WMTransferFunction1D::moduleMain(), WMTransferFunctionColorBar::moduleMain(), WMTriangleMeshRenderer::moduleMain(), WMVectorAlign::moduleMain(), WMVectorNormalize::moduleMain(), WMVectorOperator::moduleMain(), WMVectorPlot::moduleMain(), WMVectorScale::moduleMain(), WMVoxelizer::moduleMain(), WMWebglSupport::moduleMain(), WMWriteAmiraMesh::moduleMain(), WMWriteDendrogram::moduleMain(), WMWriteField::moduleMain(), WMWriteMesh::moduleMain(), WMWriteCSV::moduleMain(), WMWriteRawData::moduleMain(), WMWriteTracts::moduleMain(), WMWriteTransferFunction::moduleMain(), WUIQtWidgetBase::realize(), WMCalculateGFA::resetGFAPool(), WMCalculateTensors::resetTensorPool(), WMDeterministicFTMori::resetTracking(), WConditionSetTest::testAddRemove(), WConditionSetTest::testWait(), WConditionSetTest::testWaitResetable(), and WModule::WModule().

+ Here is the caller graph for this function:

◆ conditionFired()

void WConditionSet::conditionFired ( )
protectedvirtual

Notifier function getting notified whenever a condition got fired.

Definition at line 85 of file WConditionSet.cpp.

References notify().

+ Here is the call graph for this function:

◆ isResetable()

bool WConditionSet::isResetable ( )

Returns whether the condition set acts like a one shot condition.

Returns
true if the fire state is delayed and can be reseted.

Definition at line 120 of file WConditionSet.cpp.

References m_resetable.

◆ notify()

void WConditionSet::notify ( )
virtual

Notifies all waiting threads.

Reimplemented from WCondition.

Definition at line 90 of file WConditionSet.cpp.

References m_fired, and WCondition::notify().

Referenced by conditionFired(), WMData::handleInputChange(), WMReadLAS::handleInputChange(), WMReadSimpleTextLineData::handleInputChange(), WMReadVIM::handleInputChange(), WMTemplateDataLoader::handleInputChange(), WMFilterProtonData::moduleMain(), and WMPickingDVR::moduleMain().

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

◆ remove()

void WConditionSet::remove ( std::shared_ptr< WCondition condition)
virtual

Removes the specified condition.

As add() this immediately takes effect on running wait() calls.

Parameters
conditionthe condition to remove

Definition at line 69 of file WConditionSet.cpp.

References m_conditionSet, and m_conditionSetLock.

Referenced by WMOpenIGTLinkSender::moduleMain(), WMScalarSegmentation::moduleMain(), WMDeterministicFTMori::resetEigenFunction(), WMEigenSystem::resetEigenFunction(), WMCalculateGFA::resetGFAPool(), WMCalculateTensors::resetTensorPool(), WMDeterministicFTMori::resetTracking(), WConditionSetTest::testAddRemove(), and WConditionSetTest::testWait().

+ Here is the caller graph for this function:

◆ reset()

void WConditionSet::reset ( ) const
virtual

Resets the internal fire state.

This does nothing if !isResetable().

Definition at line 109 of file WConditionSet.cpp.

References m_fired.

Referenced by WConditionSetTest::testResetOnNotResetable(), WConditionSetTest::testWait(), and wait().

+ Here is the caller graph for this function:

◆ setResetable()

void WConditionSet::setResetable ( bool  resetable = true,
bool  autoReset = true 
)

Sets the resetable flag.

This causes the condition set to act like a WConditionOneShot. There are several implications to this you should consider when using the condition set as a resetable. If one condition in the condition set fires, a subsequent call to wait() will immediately return until a reset() call has been done. If you share one condition set among several threads, you should consider, that one thread can reset the condition set before the other thread had a chance to call wait() which causes the other thread to wait until the next condition in the set fires.

Parameters
resetabletrue if the fire state should be delayed and can be reseted.
autoResettrue if the state should be reset whenever a wait call is called and continues.This is especially useful if a condition set is used only by one thread, so there is no need to call reset() explicitly.

Definition at line 114 of file WConditionSet.cpp.

References m_autoReset, and m_resetable.

Referenced by WMAnisotropicFiltering::moduleMain(), WMApplyMask::moduleMain(), WMArbitraryPlane::moduleMain(), WMArbitraryROIs::moduleMain(), WMButterfly::moduleMain(), WMCalculateGFA::moduleMain(), WMCalculateHistogram::moduleMain(), WMCalculateTensors::moduleMain(), WMClusterDisplay::moduleMain(), WMClusterDisplayVoxels::moduleMain(), WMColormapper::moduleMain(), WMCoordinateSystem::moduleMain(), WMData::moduleMain(), WMWriteNIfTI::moduleMain(), WMDataCreatorFibers::moduleMain(), WMDataCreatorPoints::moduleMain(), WMDataCreatorScalar::moduleMain(), WMDataCreatorVector::moduleMain(), WMDatasetManipulator::moduleMain(), WMDatasetProfile::moduleMain(), WMDeterministicFTMori::moduleMain(), WMDiffTensorScalars::moduleMain(), WMDirectVolumeRendering::moduleMain(), WMDistanceMap::moduleMain(), WMEEGView::moduleMain(), WMEffectiveConnectivityCluster::moduleMain(), WMEigenSystem::moduleMain(), WMFiberDisplay::moduleMain(), WMFiberFilterIndex::moduleMain(), WMFiberFilterROI::moduleMain(), WMFiberParameterColoring::moduleMain(), WMFiberResampling::moduleMain(), WMFiberSelection::moduleMain(), WMFibersToPoints::moduleMain(), WMFiberTransform::moduleMain(), WMFiberTranslator::moduleMain(), WMFilterProtonData::moduleMain(), WMFunctionalMRIViewer::moduleMain(), WMGaussFiltering::moduleMain(), WMGridRenderer::moduleMain(), WMHARDIToSphericalHarmonics::moduleMain(), WMHierchClustDisplay::moduleMain(), WMPartition2Mesh::moduleMain(), WMHistogramEqualization::moduleMain(), WMHistogramView::moduleMain(), WMMultiHistogramView::moduleMain(), WMImageExtractor::moduleMain(), WMImageSpaceLIC::moduleMain(), WMImageSpaceTensorLIC::moduleMain(), WMIsosurface::moduleMain(), WMIsosurfaceRaytracer::moduleMain(), WMMergeComponentsToVector::moduleMain(), WMMergePoints::moduleMain(), WMMeshToPoints::moduleMain(), WMNavigationSlices::moduleMain(), WMOpenIGTLinkSender::moduleMain(), WMPaintTexture::moduleMain(), WMPickingDVR::moduleMain(), WMPickingDVREvaluation::moduleMain(), WMPointConnector::moduleMain(), WMPointRenderer::moduleMain(), WMProbTractDisplay::moduleMain(), WMProjectionsAsContext::moduleMain(), WMReadLAS::moduleMain(), WMReadSimpleTextLineData::moduleMain(), WMReadVIM::moduleMain(), WMSampleOnFibers::moduleMain(), WMScalarOperator::moduleMain(), WMScalarSegmentation::moduleMain(), WMSpatialDerivative::moduleMain(), WMSplineSurface::moduleMain(), WMSuperquadricGlyphs::moduleMain(), WMSurfaceIllustrator::moduleMain(), WMSurfaceParameterAnimator::moduleMain(), WMTemplate::moduleMain(), WMTemplateColormapping::moduleMain(), WMTemplateContainers::moduleMain(), WMTemplateDataLoader::moduleMain(), WMTemplateRenderPipelines::moduleMain(), WMTemplateShaders::moduleMain(), WMTemplateUI::moduleMain(), WMTransferFunction1D::moduleMain(), WMTransferFunctionColorBar::moduleMain(), WMTriangleMeshRenderer::moduleMain(), WMVectorAlign::moduleMain(), WMVectorNormalize::moduleMain(), WMVectorOperator::moduleMain(), WMVectorPlot::moduleMain(), WMVectorScale::moduleMain(), WMVoxelizer::moduleMain(), WMWriteCSV::moduleMain(), WMWriteTransferFunction::moduleMain(), WUIQtWidgetBase::realize(), WConditionSetTest::testResetOnNotResetable(), WConditionSetTest::testWait(), WConditionSetTest::testWaitResetable(), and WModule::WModule().

+ Here is the caller graph for this function:

◆ wait()

void WConditionSet::wait ( ) const
virtual

Wait for the condition.

Sets the calling thread asleep. If the condition set is resetable, this will return immediately when a condition in the set fired in the past and there has been no reset() call until now.

Reimplemented from WCondition.

Definition at line 96 of file WConditionSet.cpp.

References m_autoReset, m_fired, m_resetable, reset(), and WCondition::wait().

Referenced by WMAnisotropicFiltering::moduleMain(), WMApplyMask::moduleMain(), WMArbitraryPlane::moduleMain(), WMArbitraryROIs::moduleMain(), WMButterfly::moduleMain(), WMCalculateGFA::moduleMain(), WMCalculateHistogram::moduleMain(), WMCalculateTensors::moduleMain(), WMClusterDisplay::moduleMain(), WMClusterDisplayVoxels::moduleMain(), WMColormapper::moduleMain(), WMCoordinateSystem::moduleMain(), WMData::moduleMain(), WMReadSphericalHarmonics::moduleMain(), WMWriteNIfTI::moduleMain(), WMDataCreatorFibers::moduleMain(), WMDataCreatorPoints::moduleMain(), WMDataCreatorScalar::moduleMain(), WMDataCreatorVector::moduleMain(), WMDatasetManipulator::moduleMain(), WMDatasetProfile::moduleMain(), WMDataTypeConversion::moduleMain(), WMDeterministicFTMori::moduleMain(), WMDiffTensorScalars::moduleMain(), WMDirectVolumeRendering::moduleMain(), WMDistanceMap::moduleMain(), WMEEGView::moduleMain(), WMEffectiveConnectivityCluster::moduleMain(), WMEigenSystem::moduleMain(), WMFiberDisplay::moduleMain(), WMFiberFilterIndex::moduleMain(), WMFiberFilterROI::moduleMain(), WMFiberParameterColoring::moduleMain(), WMFiberResampling::moduleMain(), WMFiberSelection::moduleMain(), WMFibersToPoints::moduleMain(), WMFiberTransform::moduleMain(), WMFiberTranslator::moduleMain(), WMFilterProtonData::moduleMain(), WMFunctionalMRIViewer::moduleMain(), WMGaussFiltering::moduleMain(), WMGridRenderer::moduleMain(), WMHARDIToSphericalHarmonics::moduleMain(), WMHierchClustDisplay::moduleMain(), WMPartition2Mesh::moduleMain(), WMHistogramEqualization::moduleMain(), WMHistogramView::moduleMain(), WMMultiHistogramView::moduleMain(), WMImageExtractor::moduleMain(), WMImageSpaceLIC::moduleMain(), WMImageSpaceTensorLIC::moduleMain(), WMIsosurface::moduleMain(), WMIsosurfaceRaytracer::moduleMain(), WMMergeComponentsToVector::moduleMain(), WMMergePoints::moduleMain(), WMMeshToPoints::moduleMain(), WMNavigationSlices::moduleMain(), WMOpenIGTLinkSender::moduleMain(), WMPaintTexture::moduleMain(), WMPickingDVR::moduleMain(), WMPickingDVREvaluation::moduleMain(), WMPointConnector::moduleMain(), WMPointRenderer::moduleMain(), WMProbTractDisplay::moduleMain(), WMProjectionsAsContext::moduleMain(), WMReadAmiraMesh::moduleMain(), WMReadDipoles::moduleMain(), WMReadLAS::moduleMain(), WMReadMesh::moduleMain(), WMReadRawData::moduleMain(), WMReadSimpleTextLineData::moduleMain(), WMReadVCL::moduleMain(), WMReadVIM::moduleMain(), WMResampleRegular::moduleMain(), WMSampleOnFibers::moduleMain(), WMScalarOperator::moduleMain(), WMScalarSegmentation::moduleMain(), WMSpatialDerivative::moduleMain(), WMSplineSurface::moduleMain(), WMSuperquadricGlyphs::moduleMain(), WMSurfaceIllustrator::moduleMain(), WMSurfaceParameterAnimator::moduleMain(), WMTeemGlyphs::moduleMain(), WMTemplate::moduleMain(), WMTemplateColormapping::moduleMain(), WMTemplateDataLoader::moduleMain(), WMTemplateRenderPipelines::moduleMain(), WMTemplateShaders::moduleMain(), WMTemplateUI::moduleMain(), WMTransferFunction1D::moduleMain(), WMTransferFunctionColorBar::moduleMain(), WMTriangleMeshRenderer::moduleMain(), WMVectorAlign::moduleMain(), WMVectorNormalize::moduleMain(), WMVectorOperator::moduleMain(), WMVectorPlot::moduleMain(), WMVectorScale::moduleMain(), WMVoxelizer::moduleMain(), WMWebglSupport::moduleMain(), WMWriteAmiraMesh::moduleMain(), WMWriteDendrogram::moduleMain(), WMWriteField::moduleMain(), WMWriteMesh::moduleMain(), WMWriteCSV::moduleMain(), WMWriteRawData::moduleMain(), WMWriteTracts::moduleMain(), WMWriteTransferFunction::moduleMain(), WUIQtWidgetBase::realize(), WConditionSetTest::testWait(), and WConditionSetTest::testWaitResetable().

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

Friends And Related Function Documentation

◆ WConditionSetTest

friend class WConditionSetTest
friend

Access for test class.

Definition at line 45 of file WConditionSet.h.

Member Data Documentation

◆ m_autoReset

bool WConditionSet::m_autoReset
protected

Flag which shows whether the wait() call should reset the state m_fired when it returns.

Definition at line 127 of file WConditionSet.h.

Referenced by setResetable(), and wait().

◆ m_conditionSet

ConditionConnectionMap WConditionSet::m_conditionSet
protected

Set of conditions to be waited for.

Definition at line 138 of file WConditionSet.h.

Referenced by add(), remove(), WConditionSetTest::testAddRemove(), and ~WConditionSet().

◆ m_conditionSetLock

std::shared_mutex WConditionSet::m_conditionSetLock
protected

Lock used for thread-safe writing to the condition set.

Definition at line 148 of file WConditionSet.h.

Referenced by add(), remove(), and ~WConditionSet().

◆ m_fired

bool WConditionSet::m_fired
mutableprotected

Flag denoting whether one condition fired in the past.

Just useful when m_resetable is true.

Definition at line 158 of file WConditionSet.h.

Referenced by notify(), reset(), WConditionSetTest::testWait(), WConditionSetTest::testWaitResetable(), and wait().

◆ m_notifier

WCondition::t_ConditionNotifierType WConditionSet::m_notifier
protected

The notifier which gets called by all conditions if they fire.

Definition at line 163 of file WConditionSet.h.

Referenced by add().

◆ m_resetable

bool WConditionSet::m_resetable
protected

Flag denoting whether the condition set should act like a one shot condition.

Definition at line 122 of file WConditionSet.h.

Referenced by isResetable(), setResetable(), and wait().


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