OpenWalnut  1.4.0
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
WSharedObjectTicketRead< Data > Class Template Reference

Class which represents granted access to a locked object. More...

#include <WSharedObjectTicketRead.h>

+ Inheritance diagram for WSharedObjectTicketRead< Data >:

Public Member Functions

virtual ~WSharedObjectTicketRead ()
 Destroys the ticket and releases the lock.
const Data & get () const
 Returns the protected data.
- Public Member Functions inherited from WSharedObjectTicket< Data >
virtual ~WSharedObjectTicket ()
 Destroys the ticket and releases the lock.
void suppressUnlockCondition ()
 If called, the unlock will NOT fire the condition.

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 Member Functions inherited from WSharedObjectTicket< Data >
 WSharedObjectTicket (Data &data, boost::shared_ptr< boost::shared_mutex > mutex, boost::shared_ptr< WCondition > condition)
 Create a new instance.

Protected Attributes

boost::shared_lock
< boost::shared_mutex > 
m_lock
 The lock.
- Protected Attributes inherited from WSharedObjectTicket< Data >
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< WConditionm_condition
 A condition which gets notified after unlocking.

Friends

class WSharedObject< Data >

Detailed Description

template<typename Data>
class WSharedObjectTicketRead< 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.

Constructor & Destructor Documentation

template<typename Data >
virtual WSharedObjectTicketRead< Data >::~WSharedObjectTicketRead ( )
inlinevirtual

Destroys the ticket and releases the lock.

Definition at line 46 of file WSharedObjectTicketRead.h.

References WSharedObjectTicketRead< Data >::unlock().

template<typename Data >
WSharedObjectTicketRead< Data >::WSharedObjectTicketRead ( Data &  data,
boost::shared_ptr< boost::shared_mutex >  mutex,
boost::shared_ptr< WCondition condition 
)
inlineprotected

Create a new instance.

It is protected to avoid someone to create them. It locks the mutex for read.

Parameters
datathe data to protect
mutexthe mutex used to lock
conditiona condition that should be fired upon unlock. Can be NULL.

Definition at line 72 of file WSharedObjectTicketRead.h.

Member Function Documentation

template<typename Data >
const Data& WSharedObjectTicketRead< Data >::get ( ) const
inline

Returns the protected data.

As long as you own the ticket, you are allowed to use it.

Notes:
making it const enforces const correctness for contained types!
Returns
the data (const!)

Definition at line 59 of file WSharedObjectTicketRead.h.

template<typename Data >
virtual void WSharedObjectTicketRead< Data >::unlock ( )
inlineprotectedvirtual

Member Data Documentation

template<typename Data >
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().


The documentation for this class was generated from the following file: