OpenWalnut
1.4.0
|
Wrapper around an object/type for thread safe sharing of objects among multiple threads. More...
#include <WSharedObject.h>
Public Types | |
typedef T | ValueT |
The type protected by this shared object class. | |
typedef boost::shared_ptr < WSharedObjectTicketRead< T > > | ReadTicket |
Type for read tickets. | |
typedef boost::shared_ptr < WSharedObjectTicketWrite< T > > | WriteTicket |
Type for write tickets. | |
typedef boost::shared_ptr < WSharedObject< T > > | SPtr |
Shared pointer abbreviation. | |
typedef boost::shared_ptr < WSharedObject< T > > | ConstSPtr |
Const shared ptr abbreviation. | |
Public Member Functions | |
WSharedObject () | |
Default constructor. | |
virtual | ~WSharedObject () |
Destructor. | |
ReadTicket | getReadTicket () const |
Returns a ticket to get read access to the contained data. | |
WriteTicket | getWriteTicket (bool suppressNotify=false) const |
Returns a ticket to get write access to the contained data. | |
boost::shared_ptr< WCondition > | getChangeCondition () const |
This condition fires whenever the encapsulated object changed. | |
Protected Attributes | |
T | m_object |
The object wrapped by this class. | |
boost::shared_ptr < boost::shared_mutex > | m_lock |
The lock to ensure thread safe access. | |
boost::shared_ptr< WCondition > | m_changeCondition |
This condition set fires whenever the contained object changes. |
Wrapper around an object/type for thread safe sharing of objects among multiple threads.
The advantage of this class over WFlag is, that WFlag just protects simple get/set operations, while this class can protect a whole bunch of operations on the encapsulated object.
Definition at line 41 of file WSharedObject.h.
typedef boost::shared_ptr< WSharedObject< T > > WSharedObject< T >::ConstSPtr |
Const shared ptr abbreviation.
Reimplemented in WItemSelection.
Definition at line 77 of file WSharedObject.h.
typedef boost::shared_ptr< WSharedObjectTicketRead< T > > WSharedObject< T >::ReadTicket |
Type for read tickets.
Definition at line 62 of file WSharedObject.h.
typedef boost::shared_ptr< WSharedObject< T > > WSharedObject< T >::SPtr |
Shared pointer abbreviation.
Reimplemented in WItemSelection.
Definition at line 72 of file WSharedObject.h.
typedef T WSharedObject< T >::ValueT |
The type protected by this shared object class.
Definition at line 57 of file WSharedObject.h.
typedef boost::shared_ptr< WSharedObjectTicketWrite< T > > WSharedObject< T >::WriteTicket |
Type for write tickets.
Definition at line 67 of file WSharedObject.h.
WSharedObject< T >::WSharedObject | ( | ) |
Default constructor.
Definition at line 124 of file WSharedObject.h.
WSharedObject< T >::~WSharedObject | ( | ) | [virtual] |
Destructor.
Definition at line 132 of file WSharedObject.h.
boost::shared_ptr< WCondition > WSharedObject< T >::getChangeCondition | ( | ) | const |
This condition fires whenever the encapsulated object changed.
This is fired automatically by endWrite().
Definition at line 138 of file WSharedObject.h.
Referenced by WGEColormapping::getChangeCondition(), WGEScreenCapture::getRecordCondition(), WGEColormapping::WGEColormapping(), and WPropertyGroupBase::WPropertyGroupBase().
WSharedObject< T >::ReadTicket WSharedObject< T >::getReadTicket | ( | ) | const |
Returns a ticket to get read access to the contained data.
After the ticket is freed, the read lock vanishes.
Definition at line 144 of file WSharedObject.h.
Referenced by WLogger::addLogMessage(), WSharedSequenceContainer< S >::at(), WGEGridNode::callback(), WGEColormapping::callback(), WSharedAssociativeContainer< T >::count(), WSharedSequenceContainer< S >::count(), WModuleFactory::create(), WSharedAssociativeContainer< T >::empty(), WSharedSequenceContainer< S >::find(), WModuleFactory::findByUUID(), WPropertyGroupBase::findProperty(), WModuleFactory::getAllPrototypes(), WPropertyList< T >::getAsString(), WPropertyStruct< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::getAsString(), WGEColormapping::getBoundingBox(), WModuleFactory::getCompatiblePrototypes(), WBatchLoader::getDataModuleList(), WModuleContainer::getDataModules(), WSubject::getDatasets(), WGEGridNode::getGrid(), WModuleContainer::getModules(), WModuleContainer::getPossibleConnections(), WPropertyGroupBase::getProperties(), WPropertyStruct< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::getProperty(), WModuleFactory::getPrototypes(), WModuleFactory::getPrototypesByType(), WPropertyGroupBase::getReadTicket(), WGEColormapping::getReadTicket(), WGEScreenCapture::getRecordingInformation(), WWorkerThreadTest::FuncType::getResult(), WThreadedFunctionTest::FuncType::getResult(), WDataHandler::getSubjectByID(), WDataHandler::getSubjects(), WModuleFactory::isPrototypeAvailable(), WGEScreenCapture::isRecording(), WSharedAssociativeContainer< T >::max_size(), WSharedSequenceContainer< S >::operator[](), WGEShader::processShader(), WGEColormapping::resetSortIndices(), WPropertyStruct< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::set(), WPropertyStruct< T0, T1, T2, T3, T4, T5, T6, T7, T8, T9 >::setAsString(), WGEShader::setDefine(), WGEColormapping::setSortIndices(), WSharedAssociativeContainer< T >::size(), WSharedSequenceContainer< S >::size(), WThreadedFunctionBase::status(), WModuleContainer::stop(), WWorkerThreadTest::FuncType::stopped(), WThreadedFunctionTest::FuncType::stopped(), WThreadedTrackingFunctionTest::testCompute(), WThreadedFunctionTest::testExceptionHandling(), WGEColormapping::updateBounds(), WProjectFile::WProjectFile(), and WPropertyGroupBase::WPropertyGroupBase().
WSharedObject< T >::WriteTicket WSharedObject< T >::getWriteTicket | ( | bool | suppressNotify = false | ) | const |
Returns a ticket to get write access to the contained data.
After the ticket is freed, the write lock vanishes.
suppressNotify | true if no notification should be send after unlocking. |
Definition at line 152 of file WSharedObject.h.
Referenced by WModuleContainer::add(), WPropertyGroupBase::addArbitraryProperty(), WGEShader::addPreprocessor(), WPropertyObserver::cancelSubscriptions(), WSharedAssociativeContainer< T >::clear(), WSharedSequenceContainer< S >::clear(), WDataHandler::clear(), WGEPostprocessingNode::clear(), WSubject::clear(), WPropertyGroup::clear(), WGEShader::clearPreprocessors(), WSharedAssociativeContainer< T >::erase(), WSharedSequenceContainer< S >::erase(), WWorkerThreadTest::FuncType::FuncType(), WThreadedFunctionTest::FuncType::FuncType(), WSubject::getDatasetsForWriting(), wtracking::WThreadedTrackingFunction::getJob(), WPropertyObserver::handled(), WThreadedFunctionTest::handleException(), WThreadedFunction< Function_T >::handleThreadDone(), WThreadedFunction< Function_T >::handleThreadException(), WGEPostprocessingNode::insert(), WSharedAssociativeContainer< T >::insert(), WModuleFactory::load(), WGEColormapping::moveDown(), WGEColormapping::moveTo(), WGEColormapping::moveToBottom(), WGEColormapping::moveToTop(), WGEColormapping::moveUp(), WPropertyObserver::observe(), WWorkerThreadTest::FuncType::operator()(), WThreadedFunctionTest::FuncType::operator()(), WThreadedTrackingFunctionTest::pntVis(), WSharedSequenceContainer< S >::pop_back(), WPropertyObserver::propertyUpdated(), WSharedSequenceContainer< S >::push_back(), WSharedSequenceContainer< S >::push_front(), WGEScreenCapture::record(), WProjectFile::registerParser(), WGEPostprocessingNode::remove(), WModuleContainer::remove(), WSharedSequenceContainer< S >::remove(), WSubject::removeDataSet(), WGEShader::removePreprocessor(), WPropertyGroup::removeProperty(), WDataHandler::removeSubject(), WSharedSequenceContainer< S >::replace(), WWorkerThreadTest::FuncType::reset(), WThreadedFunctionTest::FuncType::reset(), WGEScreenCapture::resetFrameCounter(), WGEGridNode::setGrid(), WSharedSequenceContainer< S >::sort(), WSharedSequenceContainer< S >::stableSort(), WModuleContainer::stop(), WThreadedTrackingFunctionTest::testCompute(), WThreadedFunctionTest::testExceptionHandling(), WGEColormapping::textureUpdate(), WGEColormapping::updateBounds(), WPropertyObserver::updateSubscriptions(), WGEColormapping::WGEColormapping(), WGEGridNode::WGEGridNode(), WGEScreenCapture::WGEScreenCapture(), WThreadedFunction< Function_T >::WThreadedFunction(), WThreadedFunctionBase::WThreadedFunctionBase(), and wtracking::WThreadedTrackingFunction::WThreadedTrackingFunction().
boost::shared_ptr< WCondition > WSharedObject< T >::m_changeCondition [protected] |
This condition set fires whenever the contained object changes.
This corresponds to the Observable pattern.
Definition at line 118 of file WSharedObject.h.
boost::shared_ptr< boost::shared_mutex > WSharedObject< T >::m_lock [mutable, protected] |
The lock to ensure thread safe access.
This member is mutable as the getReadTicket and getWriteTicket functions are const but need a non-const reference to m_lock.
Definition at line 113 of file WSharedObject.h.
T WSharedObject< T >::m_object [mutable, protected] |
The object wrapped by this class.
This member is mutable as the getReadTicket and getWriteTicket functions are const but need a non-const reference to m_object.
Definition at line 107 of file WSharedObject.h.