|
RAVENNAKIT
|
A lock-free (and sometimes wait-free) reader writer lock. More...
#include <atomic_rw_lock.hpp>
Classes | |
| struct | Exclusive |
| Exclusive unlock function. More... | |
| struct | Shared |
| Shared unlock function. More... | |
| struct | AccessGuard |
| Guards access to a critical region. More... | |
Public Member Functions | |
| AccessGuard< Exclusive > | lock_exclusive () |
| Attempts to acquire an exclusive lock, spinning util it succeeds, or until the loop upper bounds is reached. | |
| AccessGuard< Exclusive > | try_lock_exclusive () |
| Attempts to acquire an exclusive lock. | |
| AccessGuard< Shared > | lock_shared () |
| Attempts to acquire a shared lock, spinning util it succeeds, or until the loop upper bounds is reached. | |
| AccessGuard< Shared > | try_lock_shared () |
| Attempts to acquire a shared lock. | |
| bool | is_locked_shared () const |
| bool | is_locked_exclusively () const |
| bool | is_locked () const |
Static Public Attributes | |
| static constexpr size_t | k_loop_upper_bound = 1'000'000 |
| The max number of tries before giving up (preventing runaway code). | |
| static constexpr uint32_t | k_yield_threshold = 10 |
| The number of iterations after which a function will start yielding. | |
| static constexpr uint32_t | k_sleep_threshold = 10'000 |
| The number of iterations after which a function will start sleeping. | |
A lock-free (and sometimes wait-free) reader writer lock.
Definition at line 37 of file atomic_rw_lock.hpp.
|
inlinenodiscard |
Definition at line 204 of file atomic_rw_lock.hpp.
|
inlinenodiscard |
Definition at line 197 of file atomic_rw_lock.hpp.
|
inlinenodiscard |
Definition at line 190 of file atomic_rw_lock.hpp.
|
inlinenodiscard |
Attempts to acquire an exclusive lock, spinning util it succeeds, or until the loop upper bounds is reached.
Thread safe: yes Wait-free: no
Definition at line 100 of file atomic_rw_lock.hpp.
|
inlinenodiscard |
Attempts to acquire a shared lock, spinning util it succeeds, or until the loop upper bounds is reached.
Thread safe: yes Wait-free: no
Definition at line 148 of file atomic_rw_lock.hpp.
|
inlinenodiscard |
Attempts to acquire an exclusive lock.
Note: this call can fail if a reader is trying to get access at the same time. Thread safe: yes Wait-free: yes
Definition at line 134 of file atomic_rw_lock.hpp.
|
inlinenodiscard |
Attempts to acquire a shared lock.
This will always succeed when there is no exclusive lock. This call will always succeed if there are no writers (waiting). Thread safe: yes Wait-free: yes
Definition at line 171 of file atomic_rw_lock.hpp.
|
staticconstexpr |
The max number of tries before giving up (preventing runaway code).
Definition at line 40 of file atomic_rw_lock.hpp.
|
staticconstexpr |
The number of iterations after which a function will start sleeping.
Definition at line 46 of file atomic_rw_lock.hpp.
|
staticconstexpr |
The number of iterations after which a function will start yielding.
Definition at line 43 of file atomic_rw_lock.hpp.