15#include <shared_mutex>
19namespace aui::detail {
21 struct MutexExtras: T {
33struct AMutex: aui::detail::MutexExtras<std::mutex>{};
52 MutexExtras::lock_shared();
79 return mState.exchange(LOCKED, std::memory_order_acquire) == UNLOCKED;
82 void unlock() noexcept {
83 mState.store(UNLOCKED, std::memory_order_release);
87 bool is_locked() const noexcept {
88 return mState == LOCKED;
92 enum State { UNLOCKED, LOCKED };
93 std::atomic<State> mState = UNLOCKED;
104 void shared_lock() {}
105 void try_shared_lock() {}
106 void shared_unlock() {}
Implements mutex interface but does nothing, useful for mocking a mutex.
Definition AMutex.h:99
Synchronization primitive that is implemented with atomic values instead of doing syscalls.
Definition AMutex.h:65
bool try_lock() noexcept
Tries to acquire the mutex without blocking.
Definition AMutex.h:78
Basic syscall-based synchronization primitive.
Definition AMutex.h:33
Like AMutex but can handle multiple locks for one thread (recursive).
Definition AMutex.h:42
Like AMutex but has shared lock type (in addition to basic lock which is unique locking) implementing...
Definition AMutex.h:49