libmoost
|
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>
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 |
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.
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.
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.
void moost::thread::token_mutex< T >::full_unlock | ( | ) | [inline] |
unlock the full_lock
Definition at line 184 of file token_mutex.hpp.
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.
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.
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.
boost::condition moost::thread::token_mutex< T >::m_cond [private] |
Definition at line 47 of file token_mutex.hpp.
bool moost::thread::token_mutex< T >::m_full_lock [private] |
Definition at line 49 of file token_mutex.hpp.
boost::mutex moost::thread::token_mutex< T >::m_mutex [private] |
Definition at line 46 of file token_mutex.hpp.
std::set<T> moost::thread::token_mutex< T >::m_tokens [private] |
Definition at line 48 of file token_mutex.hpp.