|
casacore
|
Wrapper around a pthreads mutex. More...
#include <Mutex.h>
Public Types | |
| enum | Type { Normal, ErrorCheck, Recursive, Default, Auto } |
| Define the type of mutex. More... | |
Public Member Functions | |
| Mutex (Type type=Auto) | |
| Create the mutex. More... | |
| ~Mutex () noexcept(false) | |
| Destroy the mutex. More... | |
| void | lock () |
| Lock the mutex. More... | |
| void | unlock () |
| Unlock the mutex. More... | |
| bool | trylock () |
| Try to lock the mutex. More... | |
Private Member Functions | |
| Mutex (const Mutex &) | |
| Forbid copy constructor. More... | |
| Mutex & | operator= (const Mutex &) |
| Forbid assignment. More... | |
Private Attributes | |
| pthread_mutex_t | itsMutex |
Wrapper around a pthreads mutex.
Public interface
This class is a wrapper around a pthreads mutex.
Although the Mutex class has a lock function, class ScopedMutexLock should be used to obtain a lock, because it makes locking exception-safe.
|
noexcept |
Destroy the mutex.
declaring noexcept(false) to squash compiler warning, although note that it is usually a bad idea for destructors to throw exceptions
|
private |
Forbid copy constructor.
|
inline |
Lock the mutex.
It blocks until it can get exclusive access to the lock.
Definition at line 78 of file Mutex.h.
References AIPS_UNLIKELY, and itsMutex.
Referenced by casacore::ScopedMutexLock::ScopedMutexLock().
|
inline |
|
inline |
Unlock the mutex.
Terminates if in a destructor during exception, but acceptable, since it would be a serious bug hopefully exposed by a test case.
Definition at line 87 of file Mutex.h.
References AIPS_UNLIKELY, and itsMutex.
Referenced by casacore::ScopedMutexLock::~ScopedMutexLock().
|
private |
1.8.18