OpenWalnut  1.4.0
Public Member Functions | Protected Member Functions | Protected Attributes | Friends
WSharedObjectTicket< Data > Class Template Reference

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

#include <WSharedObjectTicket.h>

+ Inheritance diagram for WSharedObjectTicket< Data >:

List of all members.

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< WConditionm_condition
 A condition which gets notified after unlocking.

Friends

class WSharedObject< Data >

Detailed Description

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

Notes:
This class does not provide any member to actually get the contained value/instance. This is done in read and write tickets.

Definition at line 43 of file WSharedObjectTicket.h.


Constructor & Destructor Documentation

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

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

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

Definition at line 77 of file WSharedObjectTicket.h.


Member Function Documentation

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

template<typename Data >
virtual void WSharedObjectTicket< Data >::unlock ( ) [protected, pure virtual]

Unlocks the mutex.

Implemented in WSharedObjectTicketRead< Data >, and WSharedObjectTicketWrite< Data >.


Member Data Documentation

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

template<typename Data >
Data& WSharedObjectTicket< Data >::m_data [protected]

The data to which access is allowed by the ticket.

Definition at line 82 of file WSharedObjectTicket.h.

template<typename Data >
boost::shared_ptr< boost::shared_mutex > WSharedObjectTicket< Data >::m_mutex [protected]

The mutex used for locking.

Definition at line 92 of file WSharedObjectTicket.h.


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