|
Ultralight C++ API 2.0.0
|
#include <Ultralight/Lock.h>
Lightweight mutex optimized for short locking periods.
Uncontended lock and unlock are a single inline atomic operation. Contended waiters spin briefly, then block in the OS until the lock is released (no CPU is consumed while waiting).
Can be used in place of std::mutex since it implements the STL's Lockable interface.
Public Member Functions | |
| constexpr | Lock ()=default |
| UL_ALWAYS_INLINE void | lock () noexcept |
| UL_ALWAYS_INLINE bool | try_lock () noexcept |
| UL_ALWAYS_INLINE void | unlock () noexcept |
Protected Member Functions | |
| Lock (const Lock &)=delete | |
| Lock & | operator= (const Lock &)=delete |
| void | contended_lock () noexcept |
| void | contended_unlock () noexcept |
Static Protected Member Functions | |
| static uint32_t | current_thread_id () noexcept |
Protected Attributes | |
| std::atomic< uint32_t > | state_ = { kUnlocked } |
| std::atomic< uint32_t > | owner_ = { 0 } |
Static Protected Attributes | |
| static constexpr uint32_t | kUnlocked = 0 |
| static constexpr uint32_t | kLocked = 1 |
| static constexpr uint32_t | kLockedContended = 2 |
|
constexprdefault |
|
protecteddelete |
|
protectednoexcept |
|
protectednoexcept |
|
staticprotectednoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
staticconstexprprotected |
|
staticconstexprprotected |
|
staticconstexprprotected |
|
protected |
|
protected |