OpenWalnut
1.5.0dev
|
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. More... | |
void | suppressUnlockCondition () |
If called, the unlock will NOT fire the condition. More... | |
Protected Member Functions | |
WSharedObjectTicket (Data &data, std::shared_ptr< std::shared_mutex > mutex, std::shared_ptr< WCondition > condition) | |
Create a new instance. More... | |
virtual void | unlock ()=0 |
Unlocks the mutex. More... | |
Protected Attributes | |
Data & | m_data |
The data to which access is allowed by the ticket. More... | |
std::shared_ptr< std::shared_mutex > | m_mutex |
The mutex used for locking. More... | |
std::shared_ptr< WCondition > | m_condition |
A condition which gets notified after unlocking. More... | |
Friends | |
class | WSharedObject< Data > |
The shared object class needs protected access to create new instances. More... | |
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 45 of file WSharedObjectTicket.h.
|
inlinevirtual |
Destroys the ticket and releases the lock.
Definition at line 55 of file WSharedObjectTicket.h.
References WSharedObjectTicket< Data >::m_condition.
|
inlineprotected |
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 81 of file WSharedObjectTicket.h.
|
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 68 of file WSharedObjectTicket.h.
References WSharedObjectTicket< Data >::m_condition.
|
protectedpure virtual |
Unlocks the mutex.
Implemented in WSharedObjectTicketWrite< Data >, and WSharedObjectTicketRead< Data >.
|
friend |
The shared object class needs protected access to create new instances.
Definition at line 1 of file WSharedObjectTicket.h.
|
protected |
A condition which gets notified after unlocking.
Especially useful to notify waiting threads about a change in the object.
Definition at line 101 of file WSharedObjectTicket.h.
Referenced by WSharedObjectTicket< Data >::suppressUnlockCondition(), and WSharedObjectTicket< Data >::~WSharedObjectTicket().
|
protected |
The data to which access is allowed by the ticket.
Definition at line 91 of file WSharedObjectTicket.h.
|
protected |
The mutex used for locking.
Definition at line 96 of file WSharedObjectTicket.h.