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

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

#include <WSharedObjectTicketWrite.h>

+ Inheritance diagram for WSharedObjectTicketWrite< Data >:

List of all members.

Public Member Functions

virtual ~WSharedObjectTicketWrite ()
 Destroys the ticket and releases the lock.
Data & get () const
 Returns the protected data.

Protected Member Functions

 WSharedObjectTicketWrite (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::unique_lock
< boost::shared_mutex > 
m_lock
 The lock.

Friends

class WSharedObject< Data >

Detailed Description

template<typename Data>
class WSharedObjectTicketWrite< 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 exclusive (write) lock.

Definition at line 38 of file WSharedObjectTicketWrite.h.


Constructor & Destructor Documentation

template<typename Data >
virtual WSharedObjectTicketWrite< Data >::~WSharedObjectTicketWrite ( ) [inline, virtual]

Destroys the ticket and releases the lock.

Definition at line 46 of file WSharedObjectTicketWrite.h.

References WSharedObjectTicketWrite< Data >::unlock().

template<typename Data >
WSharedObjectTicketWrite< Data >::WSharedObjectTicketWrite ( 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 write.

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

Definition at line 70 of file WSharedObjectTicketWrite.h.


Member Function Documentation

template<typename Data >
Data& WSharedObjectTicketWrite< Data >::get ( ) const [inline]

Returns the protected data.

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

Returns:
the data

Definition at line 57 of file WSharedObjectTicketWrite.h.

template<typename Data >
virtual void WSharedObjectTicketWrite< Data >::unlock ( ) [inline, protected, virtual]

Member Data Documentation

template<typename Data >
boost::unique_lock< boost::shared_mutex > WSharedObjectTicketWrite< Data >::m_lock [protected]

The lock.

Definition at line 74 of file WSharedObjectTicketWrite.h.

Referenced by WSharedObjectTicketWrite< Data >::unlock().


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