![]() |
Kea
1.5.0
|
This holds a lock on a Mutex. More...
#include <sync.h>
Inheritance diagram for isc::util::thread::Mutex::Locker:Classes | |
| struct | AlreadyLocked |
| Exception thrown when the mutex is already locked and a non-blocking locker is attempted around it. More... | |
Public Member Functions | |
| Locker (Mutex &mutex, bool block=true) | |
| Constructor. More... | |
| ~Locker () | |
| Destructor. More... | |
This holds a lock on a Mutex.
To lock a mutex, create a locker. It'll get unlocked when the locker is destroyed.
If you create the locker on the stack or using some other "garbage collecting" mechanism (unique_ptr, for example), it ensures exception safety with regards to the mutex - it'll get released on the exit of function no matter by what means.
|
inline |
Constructor.
Locks the mutex. May block for extended period of time if block is true.
| isc::InvalidOperation | when OS reports error. This usually means an attempt to use the mutex in a wrong way (locking a mutex second time from the same thread, for example). |
| AlreadyLocked | if block is false and the mutex is already locked. |
Definition at line 92 of file sync.h.
References isc_throw.
|
inline |