Wrapper around an object/type for thread safe sharing of objects among multiple threads. More...
#include <WSharedObject.h>
Public Types | |
typedef boost::shared_ptr < WSharedObjectTicketRead< T > > | ReadTicket |
Type for read tickets. | |
typedef boost::shared_ptr < WSharedObjectTicketWrite< T > > | WriteTicket |
Type for write tickets. | |
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< WSharedObjectTicketRead< T > > WSharedObject< T >::ReadTicket |
Type for read tickets.
Definition at line 58 of file WSharedObject.h.
typedef boost::shared_ptr< WSharedObjectTicketWrite< T > > WSharedObject< T >::WriteTicket |
Type for write tickets.
Definition at line 63 of file WSharedObject.h.
WSharedObject< T >::WSharedObject | ( | ) |
Default constructor.
Definition at line 111 of file WSharedObject.h.
WSharedObject< T >::~WSharedObject | ( | ) | [virtual] |
Destructor.
Definition at line 119 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 125 of file WSharedObject.h.
References WSharedObject< T >::m_changeCondition.
Referenced by WGEColormapping::getChangeCondition(), WGEColormapping::WGEColormapping(), and WProperties::WProperties().
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 131 of file WSharedObject.h.
References WSharedObject< T >::m_lock, and WSharedObject< T >::m_object.
Referenced by WLogger::addLogMessage(), WGEGridNode::callback(), WGEColormapping::callback(), WSharedAssociativeContainer< T >::count(), WModuleFactory::create(), WSharedAssociativeContainer< T >::empty(), WProperties::findProperty(), WGEColormapping::getBoundingBox(), WModuleFactory::getCompatiblePrototypes(), WModuleContainer::getDataModules(), WSubject::getDatasets(), WGEGridNode::getGrid(), WModuleContainer::getModules(), WModuleContainer::getPossibleConnections(), WProperties::getProperties(), WModuleFactory::getPrototypes(), WModuleFactory::getPrototypesByType(), WProperties::getReadTicket(), WGEColormapping::getReadTicket(), WWorkerThreadTest::FuncType::getResult(), WThreadedFunctionTest::FuncType::getResult(), WDataHandler::getSubjectByID(), WDataHandler::getSubjects(), WModuleFactory::isPrototypeAvailable(), WModuleFactory::load(), WSharedAssociativeContainer< T >::max_size(), WGEShader::processShader(), WGEShader::setDefine(), WSharedAssociativeContainer< T >::size(), WThreadedFunctionBase::status(), WModuleContainer::stop(), WWorkerThreadTest::FuncType::stopped(), WThreadedFunctionTest::FuncType::stopped(), WThreadedTrackingFunctionTest::testCompute(), WThreadedFunctionTest::testExceptionHandling(), WGEColormapping::updateBounds(), and WProperties::WProperties().
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 139 of file WSharedObject.h.
References WSharedObject< T >::m_changeCondition, WSharedObject< T >::m_lock, and WSharedObject< T >::m_object.
Referenced by WModuleContainer::add(), WGEShader::addPreprocessor(), WProperties::addProperty(), WPropertyObserver::cancelSubscriptions(), WSubject::clear(), WSharedAssociativeContainer< T >::clear(), WProperties::clear(), WGEPostprocessingNode::clear(), WDataHandler::clear(), WGEShader::clearPreprocessors(), WSharedAssociativeContainer< T >::erase(), WWorkerThreadTest::FuncType::FuncType(), WThreadedFunctionTest::FuncType::FuncType(), WSubject::getDatasetsForWriting(), wtracking::WThreadedTrackingFunction::getJob(), WPropertyObserver::handled(), WThreadedFunctionTest::handleException(), WThreadedFunction< Function_T >::handleThreadDone(), WThreadedFunction< Function_T >::handleThreadException(), WSharedAssociativeContainer< T >::insert(), WGEPostprocessingNode::insert(), WModuleFactory::load(), WGEColormapping::moveDown(), WGEColormapping::moveUp(), WPropertyObserver::observe(), WWorkerThreadTest::FuncType::operator()(), WThreadedFunctionTest::FuncType::operator()(), WThreadedTrackingFunctionTest::pntVis(), WPropertyObserver::propertyUpdated(), WModuleContainer::remove(), WGEPostprocessingNode::remove(), WSubject::removeDataSet(), WGEShader::removePreprocessor(), WProperties::removeProperty(), WDataHandler::removeSubject(), WWorkerThreadTest::FuncType::reset(), WThreadedFunctionTest::FuncType::reset(), WThreadedFunction< Function_T >::run(), WGEGridNode::setGrid(), WThreadedFunction< Function_T >::stop(), WModuleContainer::stop(), WThreadedTrackingFunctionTest::testCompute(), WThreadedFunctionTest::testExceptionHandling(), WGEColormapping::textureUpdate(), WGEColormapping::updateBounds(), WPropertyObserver::updateSubscriptions(), WGEColormapping::WGEColormapping(), WGEGridNode::WGEGridNode(), 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 105 of file WSharedObject.h.
Referenced by WSharedObject< T >::getChangeCondition(), and WSharedObject< T >::getWriteTicket().
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 100 of file WSharedObject.h.
Referenced by WSharedObject< T >::getReadTicket(), and WSharedObject< T >::getWriteTicket().
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 94 of file WSharedObject.h.
Referenced by WSharedObject< T >::getReadTicket(), and WSharedObject< T >::getWriteTicket().