Honeycomb  0.1
Component-Model Framework
Public Types | Public Member Functions | List of all members
honey::UniqueLock< Lockable_ > Class Template Reference

A scoped lock that references any lockable. Locks on construction and unlocks on destruction. More...

#include <Mutex.h>

Inheritance diagram for honey::UniqueLock< Lockable_ >:
Inheritance graph
[legend]
Collaboration diagram for honey::UniqueLock< Lockable_ >:
Collaboration graph
[legend]

Public Types

typedef Lockable_ Lockable
 

Public Member Functions

 UniqueLock ()
 
 UniqueLock (Lockable &lock, lock::Op op=lock::Op::lock)
 Construct with a reference to a mutex and an operation to perform on construction. More...
 
template<class Rep , class Period >
 UniqueLock (Lockable &lock, Duration< Rep, Period > time)
 
template<class Clock , class Dur >
 UniqueLock (Lockable &lock, TimePoint< Clock, Dur > time)
 
 UniqueLock (UniqueLock &&rhs) noexcept
 
 UniqueLock (SharedLock< Lockable > &&rhs)
 Unlock shared lock (reader) and block until unique lock (writer) is acquired. The shared lock is released. More...
 
 ~UniqueLock ()
 Unlock the mutex if we own it. More...
 
UniqueLockoperator= (UniqueLock &&rhs)
 
UniqueLockoperator= (SharedLock< Lockable > &&rhs)
 
void lock ()
 
void unlock ()
 
bool tryLock ()
 
template<class Rep , class Period >
bool tryLock (Duration< Rep, Period > time)
 
template<class Clock , class Dur >
bool tryLock (TimePoint< Clock, Dur > time)
 
bool owns () const
 Check if mutex is locked by this instance. More...
 
 operator bool () const
 Same as owns() More...
 
Lockablemutex ()
 Get the referenced mutex. More...
 
Lockablerelease ()
 Release the mutex from further operations. The mutex will no longer be owned and its state will remain unchanged. More...
 

Detailed Description

template<class Lockable_>
class honey::UniqueLock< Lockable_ >

A scoped lock that references any lockable. Locks on construction and unlocks on destruction.

Instances are non-recursive (can't lock an instance twice), and can only be manipulated by one thread.
Note that if recursion is required, multiple instances can reference the same recursive lockable.

Member Typedef Documentation

template<class Lockable_>
typedef Lockable_ honey::UniqueLock< Lockable_ >::Lockable

Constructor & Destructor Documentation

template<class Lockable_>
honey::UniqueLock< Lockable_ >::UniqueLock ( )
inline
template<class Lockable_>
honey::UniqueLock< Lockable_ >::UniqueLock ( Lockable lock,
lock::Op  op = lock::Op::lock 
)
inline

Construct with a reference to a mutex and an operation to perform on construction.

template<class Lockable_>
template<class Rep , class Period >
honey::UniqueLock< Lockable_ >::UniqueLock ( Lockable lock,
Duration< Rep, Period >  time 
)
inline
template<class Lockable_>
template<class Clock , class Dur >
honey::UniqueLock< Lockable_ >::UniqueLock ( Lockable lock,
TimePoint< Clock, Dur >  time 
)
inline
template<class Lockable_>
honey::UniqueLock< Lockable_ >::UniqueLock ( UniqueLock< Lockable_ > &&  rhs)
inlinenoexcept
template<class Lockable_>
honey::UniqueLock< Lockable_ >::UniqueLock ( SharedLock< Lockable > &&  rhs)
inline

Unlock shared lock (reader) and block until unique lock (writer) is acquired. The shared lock is released.

template<class Lockable_>
honey::UniqueLock< Lockable_ >::~UniqueLock ( )
inline

Unlock the mutex if we own it.

Member Function Documentation

template<class Lockable_>
void honey::UniqueLock< Lockable_ >::lock ( )
inline
template<class Lockable_>
Lockable& honey::UniqueLock< Lockable_ >::mutex ( )
inline

Get the referenced mutex.

template<class Lockable_>
honey::UniqueLock< Lockable_ >::operator bool ( ) const
inlineexplicit

Same as owns()

template<class Lockable_>
UniqueLock& honey::UniqueLock< Lockable_ >::operator= ( UniqueLock< Lockable_ > &&  rhs)
inline
template<class Lockable_>
UniqueLock& honey::UniqueLock< Lockable_ >::operator= ( SharedLock< Lockable > &&  rhs)
inline
template<class Lockable_>
bool honey::UniqueLock< Lockable_ >::owns ( ) const
inline

Check if mutex is locked by this instance.

template<class Lockable_>
Lockable& honey::UniqueLock< Lockable_ >::release ( )
inline

Release the mutex from further operations. The mutex will no longer be owned and its state will remain unchanged.

template<class Lockable_>
bool honey::UniqueLock< Lockable_ >::tryLock ( )
inline
template<class Lockable_>
template<class Rep , class Period >
bool honey::UniqueLock< Lockable_ >::tryLock ( Duration< Rep, Period >  time)
inline
template<class Lockable_>
template<class Clock , class Dur >
bool honey::UniqueLock< Lockable_ >::tryLock ( TimePoint< Clock, Dur >  time)
inline
template<class Lockable_>
void honey::UniqueLock< Lockable_ >::unlock ( )
inline

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