libmoost
moost::thread::token_mutex< T > Class Template Reference

token_mutex allows you to enter a critical section of code if you have a token that no one else does More...

#include <token_mutex.hpp>

List of all members.

Classes

class  scoped_full_lock
 locks everybody but first wait that beding are done More...
class  scoped_lock
 locks a token mutex with a given token More...
class  scoped_promote_lock
 locks everybody but first wait that beding are done More...
class  scoped_try_lock
 locks a token mutex with a given token More...

Public Member Functions

 token_mutex ()
 constructor, also make sure m_full_lock is set to false
void lock (const T &token)
 lock on a given token
void unlock (const T &token)
 unlock on a given token
void full_lock ()
 lock for everybody (but first wait until pending are done)
void full_unlock ()
 unlock the full_lock
bool trylock (const T &token)
 try to lock on a given token

Private Attributes

boost::mutex m_mutex
boost::condition m_cond
std::set< T > m_tokens
bool m_full_lock

Detailed Description

template<typename T>
class moost::thread::token_mutex< T >

token_mutex allows you to enter a critical section of code if you have a token that no one else does

This allows super-granular access to thread-safe regions

Definition at line 42 of file token_mutex.hpp.


Constructor & Destructor Documentation

template<typename T>
moost::thread::token_mutex< T >::token_mutex ( ) [inline]

constructor, also make sure m_full_lock is set to false

Definition at line 147 of file token_mutex.hpp.


Member Function Documentation

template<typename T>
void moost::thread::token_mutex< T >::full_lock ( ) [inline]

lock for everybody (but first wait until pending are done)

Definition at line 173 of file token_mutex.hpp.

Here is the call graph for this function:

template<typename T>
void moost::thread::token_mutex< T >::full_unlock ( ) [inline]

unlock the full_lock

Definition at line 184 of file token_mutex.hpp.

Here is the call graph for this function:

template<typename T>
void moost::thread::token_mutex< T >::lock ( const T &  token) [inline]

lock on a given token

Definition at line 152 of file token_mutex.hpp.

Here is the caller graph for this function:

template<typename T>
bool moost::thread::token_mutex< T >::trylock ( const T &  token) [inline]

try to lock on a given token

returns true if the lock was successful, immediately returns false if the lock is already held for that token

Definition at line 197 of file token_mutex.hpp.

Here is the call graph for this function:

template<typename T>
void moost::thread::token_mutex< T >::unlock ( const T &  token) [inline]

unlock on a given token

Definition at line 163 of file token_mutex.hpp.

Here is the call graph for this function:


Member Data Documentation

template<typename T>
boost::condition moost::thread::token_mutex< T >::m_cond [private]

Definition at line 47 of file token_mutex.hpp.

template<typename T>
bool moost::thread::token_mutex< T >::m_full_lock [private]

Definition at line 49 of file token_mutex.hpp.

template<typename T>
boost::mutex moost::thread::token_mutex< T >::m_mutex [private]

Definition at line 46 of file token_mutex.hpp.

template<typename T>
std::set<T> moost::thread::token_mutex< T >::m_tokens [private]

Definition at line 48 of file token_mutex.hpp.


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