Lunchbox  1.11.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
lunchbox::ScopedMutex< L, T > Class Template Reference

A scoped mutex. More...

#include <scopedMutex.h>

+ Collaboration diagram for lunchbox::ScopedMutex< L, T >:

Public Member Functions

 ScopedMutex (L *lock)
 Construct a new scoped mutex and set the given lock. More...
 
 ScopedMutex (L &lock)
 Construct a new scoped mutex and set the given lock. More...
 
 ScopedMutex (const ScopedMutex &rhs)
 Move lock from rhs to new mutex. More...
 
ScopedMutexoperator= (ScopedMutex &rhs)
 Move lock from rhs to this mutex. More...
 
template<typename LB >
 ScopedMutex (const LB &lockable)
 Construct a new scoped mutex for the given Lockable data structure. More...
 
 ~ScopedMutex ()
 Destruct the scoped mutex and unset the mutex. More...
 
void leave ()
 Leave and unlock the mutex immediately. More...
 

Detailed Description

template<class L = Lock, class T = WriteOp>
class lunchbox::ScopedMutex< L, T >

A scoped mutex.

The mutex is automatically set upon creation, and released when the scoped mutex is destroyed, e.g., when the scope is left. The scoped mutex does nothing if a 0 pointer for the lock is passed.

Deprecated:
Use boost::scoped_lock

Definition at line 59 of file scopedMutex.h.

Constructor & Destructor Documentation

template<class L = Lock, class T = WriteOp>
lunchbox::ScopedMutex< L, T >::ScopedMutex ( L *  lock)
inlineexplicit

Construct a new scoped mutex and set the given lock.

Providing no Lock (0) is allowed, in which case the scoped mutex does nothing.

Parameters
lockthe mutex to set and unset, or 0.
Version
1.0

Definition at line 73 of file scopedMutex.h.

template<class L = Lock, class T = WriteOp>
lunchbox::ScopedMutex< L, T >::ScopedMutex ( L &  lock)
inlineexplicit

Construct a new scoped mutex and set the given lock.

Version
1.0

Definition at line 77 of file scopedMutex.h.

template<class L = Lock, class T = WriteOp>
lunchbox::ScopedMutex< L, T >::ScopedMutex ( const ScopedMutex< L, T > &  rhs)
inline

Move lock from rhs to new mutex.

Version
1.5

Definition at line 81 of file scopedMutex.h.

template<class L = Lock, class T = WriteOp>
template<typename LB >
lunchbox::ScopedMutex< L, T >::ScopedMutex ( const LB &  lockable)
inlineexplicit

Construct a new scoped mutex for the given Lockable data structure.

Version
1.0

Definition at line 99 of file scopedMutex.h.

template<class L = Lock, class T = WriteOp>
lunchbox::ScopedMutex< L, T >::~ScopedMutex ( )
inline

Destruct the scoped mutex and unset the mutex.

Version
1.0

Definition at line 103 of file scopedMutex.h.

References lunchbox::ScopedMutex< L, T >::leave().

+ Here is the call graph for this function:

Member Function Documentation

template<class L = Lock, class T = WriteOp>
void lunchbox::ScopedMutex< L, T >::leave ( )
inline

Leave and unlock the mutex immediately.

Version
1.0

Definition at line 106 of file scopedMutex.h.

Referenced by lunchbox::ScopedMutex< L, T >::~ScopedMutex().

+ Here is the caller graph for this function:

template<class L = Lock, class T = WriteOp>
ScopedMutex& lunchbox::ScopedMutex< L, T >::operator= ( ScopedMutex< L, T > &  rhs)
inline

Move lock from rhs to this mutex.

Version
1.5

Definition at line 85 of file scopedMutex.h.


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