dodo
0.0.1
A C++ library to create containerized Linux services
|
A Mutex to synchronize access to resources between threads. More...
#include <mutex.hpp>
Public Member Functions | |
Mutex () | |
Construct a Mutex. More... | |
virtual | ~Mutex () |
Destruct a Mutex. More... | |
void | lock () |
Waits for a Mutex and locks it (atomically). More... | |
bool | tryLock () |
If the Mutex is currently not locked, lock it and return true. More... | |
void | unLock () |
Unlocks the Mutex. More... | |
Private Attributes | |
std::mutex | mutex_ |
the internal std::mutex More... | |
A Mutex to synchronize access to resources between threads.
Use a Mutexer to control a Mutex by mere scope.
|
inlinevirtual |
|
inline |
Waits for a Mutex and locks it (atomically).
You must not call lock if the lock is already held by the calling thread, that is a deadlock.
Definition at line 57 of file mutex.hpp.
References mutex_.
Referenced by dodo::threads::Mutexer::Mutexer().
|
inline |
If the Mutex is currently not locked, lock it and return true.
If the Mutex is locked, return false. You must not call lock if the lock is alread held by the calling thread, that is a deadlock. Mutex from the same thread twice - that is a deadlock.
Definition at line 66 of file mutex.hpp.
References mutex_.
|
inline |
Unlocks the Mutex.
Calling unLOck whilst the calling thread is not holding the lock causes undefined behavior in the Mutex.
Definition at line 73 of file mutex.hpp.
References mutex_.
Referenced by dodo::threads::Mutexer::~Mutexer().
|
private |