LogCabin
|
A wrapper around std::mutex that is useful for testing purposes. More...
#include <Mutex.h>
Public Types | |
typedef std::mutex::native_handle_type | native_handle_type |
Public Member Functions | |
Mutex () | |
void | lock () |
bool | try_lock () |
void | unlock () |
native_handle_type | native_handle () |
Public Attributes | |
std::function< void()> | callback |
This function will be called with the lock held after the lock is acquired and before it is released. | |
Private Attributes | |
std::mutex | m |
Underlying mutex. | |
Friends | |
class | ConditionVariable |
A wrapper around std::mutex that is useful for testing purposes.
You can set a callback to be called when the mutex is locked and before it is unlocked. This callback can, for example, check the invariants on the protected state.
The interface to this class is the same as std::mutex.
typedef std::mutex::native_handle_type LogCabin::Core::Mutex::native_handle_type |
LogCabin::Core::Mutex::Mutex | ( | ) | [inline] |
void LogCabin::Core::Mutex::lock | ( | ) | [inline] |
bool LogCabin::Core::Mutex::try_lock | ( | ) | [inline] |
void LogCabin::Core::Mutex::unlock | ( | ) | [inline] |
native_handle_type LogCabin::Core::Mutex::native_handle | ( | ) | [inline] |
friend class ConditionVariable [friend] |
std::mutex LogCabin::Core::Mutex::m [private] |
std::function<void()> LogCabin::Core::Mutex::callback |