|
mCRL2
|
#include <shared_mutex.h>
Public Member Functions | |
| shared_mutex () | |
| ~shared_mutex () | |
| shared_mutex (const shared_mutex &other) | |
| The copy/move constructor/assignment should not be called while any lock_guard or shared_guard is alive. | |
| shared_mutex (shared_mutex &&other) noexcept | |
| shared_mutex & | operator= (const shared_mutex &other) |
| shared_mutex & | operator= (shared_mutex &&other) noexcept |
| void | lock () |
| Obtain exclusive access, and stop all other threads that use this mutex. | |
| bool | try_lock () |
| Try to obtain exclusive access without blocking on other exclusive locks. | |
| void | unlock () |
| Release exclusive access. | |
| void | lock_shared () |
| Acquires a shared lock on this mutex. | |
| bool | try_lock_shared () |
| Tries to acquire a shared lock on this mutex without blocking. | |
| void | unlock_shared () |
| Releases a shared lock on this mutex. | |
| bool | is_shared_locked () const |
Private Member Functions | |
| void | set_forbidden_flags () |
| bool | is_busy () const |
| void | wait_for_busy () const |
| Waits for the busy flag to become false. | |
| void | set_forbidden (bool value) |
Private Attributes | |
| std::atomic< bool > | m_busy_flag = false |
| A boolean flag indicating whether this thread is working inside the global aterm pool. | |
| std::atomic< bool > | m_forbidden_flag = false |
| std::size_t | m_lock_depth = 0 |
| It can happen that un/lock_shared calls are nested, so keep track of the nesting depth and only actually perform un/locking at the root. | |
| std::shared_ptr< shared_mutex_data > | m_shared |
An implementation of a shared mutex (also called readers-write lock in the literature) based on the notion of busy and forbidden flags.
Definition at line 59 of file shared_mutex.h.
|
inline |
Definition at line 62 of file shared_mutex.h.
|
inline |
Definition at line 68 of file shared_mutex.h.
|
inline |
The copy/move constructor/assignment should not be called while any lock_guard or shared_guard is alive.
Definition at line 74 of file shared_mutex.h.
|
inlinenoexcept |
Definition at line 80 of file shared_mutex.h.
|
inlineprivate |
Definition at line 270 of file shared_mutex.h.
|
inline |
Definition at line 235 of file shared_mutex.h.
|
inline |
Obtain exclusive access, and stop all other threads that use this mutex.
Equivalent to std::shared_mutex::lock. Blocks until exclusive access is acquired.
Definition at line 117 of file shared_mutex.h.
|
inline |
Acquires a shared lock on this mutex.
Equivalent to std::shared_mutex::lock_shared, except that recursive shared locking by the owning thread is explicitly allowed: every lock_shared() must be balanced by exactly one unlock_shared().
Definition at line 171 of file shared_mutex.h.
|
inline |
Definition at line 86 of file shared_mutex.h.
|
inlinenoexcept |
Definition at line 99 of file shared_mutex.h.
|
inlineprivate |
Definition at line 283 of file shared_mutex.h.
|
inlineprivate |
Definition at line 242 of file shared_mutex.h.
|
inline |
Try to obtain exclusive access without blocking on other exclusive locks.
Equivalent to std::shared_mutex::try_lock.
Definition at line 133 of file shared_mutex.h.
|
inline |
Tries to acquire a shared lock on this mutex without blocking.
Equivalent to std::shared_mutex::try_lock_shared.
Definition at line 199 of file shared_mutex.h.
|
inline |
Release exclusive access.
Equivalent to std::shared_mutex::unlock.
Definition at line 152 of file shared_mutex.h.
|
inline |
Releases a shared lock on this mutex.
Equivalent to std::shared_mutex::unlock_shared.
Definition at line 222 of file shared_mutex.h.
|
inlineprivate |
Waits for the busy flag to become false.
Definition at line 277 of file shared_mutex.h.
|
private |
A boolean flag indicating whether this thread is working inside the global aterm pool.
Definition at line 289 of file shared_mutex.h.
|
private |
Definition at line 290 of file shared_mutex.h.
|
private |
It can happen that un/lock_shared calls are nested, so keep track of the nesting depth and only actually perform un/locking at the root.
Definition at line 294 of file shared_mutex.h.
|
private |
Definition at line 296 of file shared_mutex.h.