OpenWalnut
1.4.0
|
Class which represents granted access to a locked object. More...
#include <WSharedObjectTicket.h>
Public Member Functions | |
virtual | ~WSharedObjectTicket () |
Destroys the ticket and releases the lock. | |
void | suppressUnlockCondition () |
If called, the unlock will NOT fire the condition. | |
Protected Member Functions | |
WSharedObjectTicket (Data &data, boost::shared_ptr< boost::shared_mutex > mutex, boost::shared_ptr< WCondition > condition) | |
Create a new instance. | |
virtual void | unlock ()=0 |
Unlocks the mutex. | |
Protected Attributes | |
Data & | m_data |
The data to which access is allowed by the ticket. | |
boost::shared_ptr < boost::shared_mutex > | m_mutex |
The mutex used for locking. | |
boost::shared_ptr< WCondition > | m_condition |
A condition which gets notified after unlocking. | |
Friends | |
class | WSharedObject< Data > |
Class which represents granted access to a locked object.
It contains a reference to the object and a lock. The lock is freed after the ticket has been destroyed.
Definition at line 43 of file WSharedObjectTicket.h.
virtual WSharedObjectTicket< Data >::~WSharedObjectTicket | ( | ) | [inline, virtual] |
Destroys the ticket and releases the lock.
Definition at line 51 of file WSharedObjectTicket.h.
References WSharedObjectTicket< Data >::m_condition.
WSharedObjectTicket< Data >::WSharedObjectTicket | ( | Data & | data, |
boost::shared_ptr< boost::shared_mutex > | mutex, | ||
boost::shared_ptr< WCondition > | condition | ||
) | [inline, protected] |
Create a new instance.
It is protected to avoid someone to create them. It locks the mutex.
data | the data to protect |
mutex | the mutex used to lock |
condition | a condition that should be fired upon unlock. Can be NULL. |
Definition at line 77 of file WSharedObjectTicket.h.
void WSharedObjectTicket< Data >::suppressUnlockCondition | ( | ) | [inline] |
If called, the unlock will NOT fire the condition.
This is useful in some situations if you find out "hey there actually was nothing changed".
Definition at line 64 of file WSharedObjectTicket.h.
References WSharedObjectTicket< Data >::m_condition.
virtual void WSharedObjectTicket< Data >::unlock | ( | ) | [protected, pure virtual] |
Unlocks the mutex.
Implemented in WSharedObjectTicketRead< Data >, and WSharedObjectTicketWrite< Data >.
boost::shared_ptr< WCondition > WSharedObjectTicket< Data >::m_condition [protected] |
A condition which gets notified after unlocking.
Especially useful to notify waiting threads about a change in the object.
Definition at line 97 of file WSharedObjectTicket.h.
Referenced by WSharedObjectTicket< Data >::suppressUnlockCondition(), and WSharedObjectTicket< Data >::~WSharedObjectTicket().
Data& WSharedObjectTicket< Data >::m_data [protected] |
The data to which access is allowed by the ticket.
Definition at line 82 of file WSharedObjectTicket.h.
boost::shared_ptr< boost::shared_mutex > WSharedObjectTicket< Data >::m_mutex [protected] |
The mutex used for locking.
Definition at line 92 of file WSharedObjectTicket.h.