LogCabin
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Types | Public Member Functions | Public Attributes | Private Attributes | Friends
LogCabin::Core::Mutex Class Reference

A wrapper around std::mutex that is useful for testing purposes. More...

#include <Mutex.h>

List of all members.

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

Detailed Description

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.

Definition at line 35 of file Mutex.h.


Member Typedef Documentation

typedef std::mutex::native_handle_type LogCabin::Core::Mutex::native_handle_type

Definition at line 37 of file Mutex.h.


Constructor & Destructor Documentation

Definition at line 39 of file Mutex.h.


Member Function Documentation

void LogCabin::Core::Mutex::lock ( ) [inline]

Definition at line 46 of file Mutex.h.

Definition at line 53 of file Mutex.h.

void LogCabin::Core::Mutex::unlock ( ) [inline]

Definition at line 63 of file Mutex.h.

Definition at line 72 of file Mutex.h.


Friends And Related Function Documentation

friend class ConditionVariable [friend]

Definition at line 86 of file Mutex.h.


Member Data Documentation

std::mutex LogCabin::Core::Mutex::m [private]

Underlying mutex.

Definition at line 78 of file Mutex.h.

std::function<void()> LogCabin::Core::Mutex::callback

This function will be called with the lock held after the lock is acquired and before it is released.

Definition at line 84 of file Mutex.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines