A Mutex which uses atomic flags and spin-locks instead of halting threads.
This mutex uses an incremental back-off strategy with the following phases:
This is meant to give a good balance of perofrmance and CPU consumption in practice.
This mutex uses an incremental back-off strategy with the following phases:
This is meant to give a good balance of perofrmance and CPU consumption in practice.
This class implements the BasicLockable specification: https://en.cppreference.com/w/cpp/named_req/BasicLockable
Definition at line 52 of file includes/opentelemetry/common/spin_lock_mutex.h.
Public Member Functions | |
| SpinLockMutex () noexcept | |
| ~SpinLockMutex () noexcept=default | |
| SpinLockMutex (const SpinLockMutex &)=delete | |
| SpinLockMutex & | operator= (const SpinLockMutex &)=delete |
| bool | try_lock () noexcept |
| Attempts to lock the mutex. More... | |
| void | lock () noexcept |
| Blocks until a lock can be obtained for the current thread. More... | |
| void | unlock () noexcept |
| Releases the lock held by the execution agent. More... | |
| SpinLockMutex () noexcept | |
| ~SpinLockMutex () noexcept=default | |
| SpinLockMutex (const SpinLockMutex &)=delete | |
| SpinLockMutex & | operator= (const SpinLockMutex &)=delete |
| bool | try_lock () noexcept |
| Attempts to lock the mutex. More... | |
| void | lock () noexcept |
| Blocks until a lock can be obtained for the current thread. More... | |
| void | unlock () noexcept |
| Releases the lock held by the execution agent. More... | |
Static Public Member Functions | |
| static void | fast_yield () noexcept |
| static void | fast_yield () noexcept |
|
inlinenoexcept |
Definition at line 55 of file includes/opentelemetry/common/spin_lock_mutex.h.
|
defaultnoexcept |
|
delete |
|
inlinenoexcept |
Definition at line 55 of file 9.2/includes/opentelemetry/common/spin_lock_mutex.h.
|
defaultnoexcept |
|
delete |
|
inlinestaticnoexcept |
Definition at line 60 of file includes/opentelemetry/common/spin_lock_mutex.h.
Referenced by lock().
|
inlinestaticnoexcept |
Definition at line 60 of file 9.2/includes/opentelemetry/common/spin_lock_mutex.h.
|
inlinenoexcept |
Blocks until a lock can be obtained for the current thread.
This mutex will spin the current CPU waiting for the lock to be available. This can have decent performance in scenarios where there is low lock contention and lock-holders achieve their work quickly. It degrades in scenarios where locked tasks take a long time.
Definition at line 96 of file includes/opentelemetry/common/spin_lock_mutex.h.
References fast_yield(), common::SPINLOCK_FAST_ITERATIONS, common::SPINLOCK_SLEEP_MS, and try_lock().
|
inlinenoexcept |
Blocks until a lock can be obtained for the current thread.
This mutex will spin the current CPU waiting for the lock to be available. This can have decent performance in scenarios where there is low lock contention and lock-holders achieve their work quickly. It degrades in scenarios where locked tasks take a long time.
Definition at line 96 of file 9.2/includes/opentelemetry/common/spin_lock_mutex.h.
References fast_yield(), common::SPINLOCK_FAST_ITERATIONS, common::SPINLOCK_SLEEP_MS, and try_lock().
|
delete |
|
delete |
|
inlinenoexcept |
Attempts to lock the mutex.
Return immediately with true (success) or false (failure).
Definition at line 83 of file 9.2/includes/opentelemetry/common/spin_lock_mutex.h.
|
inlinenoexcept |
Attempts to lock the mutex.
Return immediately with true (success) or false (failure).
Definition at line 83 of file includes/opentelemetry/common/spin_lock_mutex.h.
Referenced by lock().
|
inlinenoexcept |
Releases the lock held by the execution agent.
Throws no exceptions.
Definition at line 126 of file 9.2/includes/opentelemetry/common/spin_lock_mutex.h.
|
inlinenoexcept |
Releases the lock held by the execution agent.
Throws no exceptions.
Definition at line 126 of file includes/opentelemetry/common/spin_lock_mutex.h.