|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
RAII-style mutex lock guard. More...
#include <useMutex.H>
Public Member Functions | |
| void | unlock () |
| Explicitly unlock the mutex. | |
| void | lock () |
| Explicitly lock the mutex. | |
| UseMutex (pthread_mutex_t *m) | |
| Construct and lock (pointer version) | |
| UseMutex (pthread_mutex_t &m) | |
| Construct and lock (reference version) | |
| void | enter () |
| Alias for lock() | |
| void | leave () |
| Alias for unlock() | |
| ~UseMutex () | |
| Destructor - unlocks if allowed. | |
| void | disallow_unlock () |
| Prevent automatic unlock on destruction. | |
| void | allow_unlock () |
| Allow automatic unlock on destruction (default) | |
Private Attributes | |
| pthread_mutex_t * | mutex |
| bool | unlock_when_destroy |
RAII-style mutex lock guard.
Automatically acquires a lock on construction and releases it on destruction, unless explicitly disabled.
This class wraps POSIX mutexes, providing the same thread safety guarantees as the underlying pthread_mutex_t. *
Definition at line 141 of file useMutex.H.
|
inline |
Construct and lock (pointer version)
| m | Pointer to initialized mutex * |
Definition at line 182 of file useMutex.H.
References lock().
|
inline |
Construct and lock (reference version)
| m | Reference to initialized mutex * |
Definition at line 193 of file useMutex.H.
References lock().
|
inline |
Destructor - unlocks if allowed.
Definition at line 205 of file useMutex.H.
References unlock(), and unlock_when_destroy.
|
inline |
Allow automatic unlock on destruction (default)
Definition at line 215 of file useMutex.H.
References unlock_when_destroy.
|
inline |
Prevent automatic unlock on destruction.
Definition at line 212 of file useMutex.H.
References unlock_when_destroy.
|
inline |
|
inline |
|
inline |
Explicitly lock the mutex.
| std::domain_error | if mutex pointer is null * |
Definition at line 168 of file useMutex.H.
References ah_domain_error_if, Aleph::maps(), and mutex.
Referenced by UseMutex(), UseMutex(), and enter().
|
inline |
Explicitly unlock the mutex.
| std::domain_error | if mutex pointer is null * |
Definition at line 154 of file useMutex.H.
References ah_domain_error_if, Aleph::maps(), and mutex.
Referenced by ~UseMutex(), and leave().
|
private |
Definition at line 143 of file useMutex.H.
|
private |
Definition at line 144 of file useMutex.H.
Referenced by ~UseMutex(), allow_unlock(), and disallow_unlock().