18 #ifndef LUNCHBOX_SPINLOCK_H 19 #define LUNCHBOX_SPINLOCK_H 21 #include <lunchbox/atomic.h> 22 #include <lunchbox/thread.h> 48 LUNCHBOX_API
void set();
49 void lock() {
set(); }
51 LUNCHBOX_API
void unset();
52 void unlock() {
unset(); }
59 LUNCHBOX_API
bool trySet();
63 void lock_shared() {
setRead(); }
81 LUNCHBOX_API
bool isSet();
101 std::unique_ptr<Impl> _impl;
105 SpinLock& operator=(
const SpinLock&) =
delete;
106 SpinLock& operator=(SpinLock&&) =
delete;
109 #endif // LUNCHBOX_SPINLOCK_H bool trySetRead()
Attempt to acquire the lock shared with other readers.
A fast lock for uncontended memory access.
bool isSetWrite()
Test if the lock is set exclusively.
bool trySet()
Attempt to acquire the lock exclusively.
void setRead()
Acquire the lock shared with other readers.
void unset()
Release an exclusive lock.
bool isSetRead()
Test if the lock is set shared.
~SpinLock()
Destruct the lock.
bool isSet()
Test if the lock is set.
Abstraction layer and common utilities for multi-threaded programming.
void unsetRead()
Release a shared read lock.
SpinLock()
Construct a new lock.