A mutex with the concept of 'ownership'. More...
#include <owned_mutex.h>
Public Member Functions | |
void | lock () |
Lock this mutex. More... | |
void | unlock () |
Unlock this mutex. More... | |
A mutex with the concept of 'ownership'.
Similar to a recursive mutex, this mutex can be locked multiple times by the same thread. However, a single unlock suffices to fully unlock this mutex. Upon locking, the mutex will store the thread::id of the locking thread, which is then regarded as the 'owner' of the mutex. Only the owner can lock/unlock the mutex. Upon unlocking, ownership is lost.
void twirre::owned_mutex::lock | ( | ) |
Lock this mutex.
If the mutex is currently not owned, the calling thread will take ownership of the mutex. If the mutex is owned by the calling thread itself, this operation will return without any effect. If the mutex is owned by a different thread, the calling thread will wait until ownership becomes available again, after which it will take ownership.
This mutex can be locked multiple times, and only requires a single unlock to become fully unlocked again.
void twirre::owned_mutex::unlock | ( | ) |
Unlock this mutex.
The mutex will be fully unlocked. This relinquishes ownership of the mutex, so a different thread is allowed to lock it. This operation will do nothing if this mutex is not currently owned by a thread.
std::logic_error | when lock() is called from a different thread than the current owner. |