Honeycomb  0.1
Component-Model Framework
Public Types | Public Member Functions | List of all members
honey::TransferLock< FromLock, ToLock > Class Template Reference

Scoped transfer of mutex ownership between two locks. More...

#include <Transfer.h>

Inheritance diagram for honey::TransferLock< FromLock, ToLock >:
Inheritance graph
[legend]
Collaboration diagram for honey::TransferLock< FromLock, ToLock >:
Collaboration graph
[legend]

Public Types

typedef ToLock::Lockable Lockable
 

Public Member Functions

 TransferLock (FromLock &lock)
 Transfer ownership of mutex from lock to an instance of ToLock. More...
 
 ~TransferLock ()
 
void lock ()
 
void unlock ()
 
bool owns () const
 
 operator bool () const
 
Lockablemutex ()
 
Lockablerelease ()
 

Detailed Description

template<class FromLock, class ToLock>
class honey::TransferLock< FromLock, ToLock >

Scoped transfer of mutex ownership between two locks.

Ownership is transferred to ToLock on construction, and then returned to FromLock on destruction.

This class can be used to atomically acquire a unique writer lock from a shared reader lock:

SharedMutex mutex;
SharedMutex::SharedScoped readLock(mutex);
//Read ownership acquired, read data...
{
    TransferLock<decltype(readLock), SharedMutex::Scoped> writeLock(readLock);
    //Write ownership acquired in this scope, write data...
}
//Read ownership re-acquired

Member Typedef Documentation

template<class FromLock , class ToLock >
typedef ToLock::Lockable honey::TransferLock< FromLock, ToLock >::Lockable

Constructor & Destructor Documentation

template<class FromLock , class ToLock >
honey::TransferLock< FromLock, ToLock >::TransferLock ( FromLock &  lock)
inline

Transfer ownership of mutex from lock to an instance of ToLock.

template<class FromLock , class ToLock >
honey::TransferLock< FromLock, ToLock >::~TransferLock ( )
inline

Member Function Documentation

template<class FromLock , class ToLock >
void honey::TransferLock< FromLock, ToLock >::lock ( )
inline
template<class FromLock , class ToLock >
Lockable& honey::TransferLock< FromLock, ToLock >::mutex ( )
inline
template<class FromLock , class ToLock >
honey::TransferLock< FromLock, ToLock >::operator bool ( ) const
inlineexplicit
template<class FromLock , class ToLock >
bool honey::TransferLock< FromLock, ToLock >::owns ( ) const
inline
template<class FromLock , class ToLock >
Lockable& honey::TransferLock< FromLock, ToLock >::release ( )
inline
template<class FromLock , class ToLock >
void honey::TransferLock< FromLock, ToLock >::unlock ( )
inline

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