dodo
0.0.1
A C++ library to create containerized Linux services
|
Waits for and locks the Mutex on construction, unlocks the Mutex when this Mutexer is destructed. More...
#include <mutex.hpp>
Public Member Functions | |
Mutexer (Mutex &mutex) | |
Constructor. More... | |
~Mutexer () | |
Destructor. More... | |
Private Attributes | |
Mutex & | mutex_ |
Reference to the guarded mutex. More... | |
Waits for and locks the Mutex on construction, unlocks the Mutex when this Mutexer is destructed.
In the below code, it would be safe to call addInt from multiple threads. The Mutexer object calls thelist_mutex.lock() when constructed, and thelist_mutex.unLock() when it goes out of scope( the function returns or an exception is thrown).
|
inline |
Constructor.
mutex | The mutex to guard. |
Definition at line 106 of file mutex.hpp.
References dodo::threads::Mutex::lock(), and mutex_.
|
inline |
Destructor.
Unlocks the guarded mutex.
Definition at line 112 of file mutex.hpp.
References mutex_, and dodo::threads::Mutex::unLock().
|
private |
Reference to the guarded mutex.
Definition at line 112 of file mutex.hpp.
Referenced by Mutexer(), and ~Mutexer().