OpenWalnut
1.4.0
|
Class which represents granted access to a locked object. More...
#include <WSharedObjectTicketRead.h>
Public Member Functions | |
virtual | ~WSharedObjectTicketRead () |
Destroys the ticket and releases the lock. | |
const Data & | get () const |
Returns the protected data. | |
Protected Member Functions | |
WSharedObjectTicketRead (Data &data, boost::shared_ptr< boost::shared_mutex > mutex, boost::shared_ptr< WCondition > condition) | |
Create a new instance. | |
virtual void | unlock () |
Unlocks the mutex. | |
Protected Attributes | |
boost::shared_lock < boost::shared_mutex > | m_lock |
The lock. | |
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. This class especially implements the shared (read) lock.
Definition at line 38 of file WSharedObjectTicketRead.h.
virtual WSharedObjectTicketRead< Data >::~WSharedObjectTicketRead | ( | ) | [inline, virtual] |
Destroys the ticket and releases the lock.
Definition at line 46 of file WSharedObjectTicketRead.h.
References WSharedObjectTicketRead< Data >::unlock().
WSharedObjectTicketRead< Data >::WSharedObjectTicketRead | ( | 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 for read.
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 72 of file WSharedObjectTicketRead.h.
const Data& WSharedObjectTicketRead< Data >::get | ( | ) | const [inline] |
Returns the protected data.
As long as you own the ticket, you are allowed to use it.
Definition at line 59 of file WSharedObjectTicketRead.h.
virtual void WSharedObjectTicketRead< Data >::unlock | ( | ) | [inline, protected, virtual] |
Unlocks the mutex.
Implements WSharedObjectTicket< Data >.
Definition at line 86 of file WSharedObjectTicketRead.h.
References WSharedObjectTicketRead< Data >::m_lock.
Referenced by WSharedObjectTicketRead< Data >::~WSharedObjectTicketRead().
boost::shared_lock< boost::shared_mutex > WSharedObjectTicketRead< Data >::m_lock [protected] |
The lock.
Definition at line 76 of file WSharedObjectTicketRead.h.
Referenced by WSharedObjectTicketRead< Data >::unlock().