OpenWalnut
1.5.0dev
|
Class allowing multiple conditions to be used for one waiting cycle. More...
#include <WConditionSet.h>
Public Types | |
typedef std::shared_ptr< WConditionSet > | SPtr |
Shared pointer to instance of this class. More... | |
typedef std::shared_ptr< const WConditionSet > | ConstSPtr |
Shared pointer to const instance of this class. More... | |
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... | |
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... | |
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.
|
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.
|
protected |
Each condition has a connection.
Definition at line 143 of file WConditionSet.h.
typedef std::shared_ptr< const WConditionSet > WConditionSet::ConstSPtr |
Shared pointer to const instance of this class.
Definition at line 55 of file WConditionSet.h.
typedef std::shared_ptr< WConditionSet > WConditionSet::SPtr |
Shared pointer to instance of this class.
Definition at line 50 of file WConditionSet.h.
WConditionSet::WConditionSet | ( | ) |
Default constructor.
Definition at line 29 of file WConditionSet.cpp.
|
virtual |
Destructor.
Definition at line 38 of file WConditionSet.cpp.
References m_conditionSet, and m_conditionSetLock.
|
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.
condition | the 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().
|
protectedvirtual |
Notifier function getting notified whenever a condition got fired.
Definition at line 85 of file WConditionSet.cpp.
References notify().
bool WConditionSet::isResetable | ( | ) |
Returns whether the condition set acts like a one shot condition.
Definition at line 120 of file WConditionSet.cpp.
References m_resetable.
|
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().
|
virtual |
Removes the specified condition.
As add() this immediately takes effect on running wait() calls.
condition | the 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().
|
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().
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.
resetable | true if the fire state should be delayed and can be reseted. |
autoReset | true 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().
|
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().
|
friend |
Access for test class.
Definition at line 45 of file WConditionSet.h.
|
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().
|
protected |
Set of conditions to be waited for.
Definition at line 138 of file WConditionSet.h.
Referenced by add(), remove(), WConditionSetTest::testAddRemove(), and ~WConditionSet().
|
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().
|
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().
|
protected |
The notifier which gets called by all conditions if they fire.
Definition at line 163 of file WConditionSet.h.
Referenced by add().
|
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().