Lunchbox
1.4.0
|
A fast lock for uncontended memory access. More...
#include <spinLock.h>
Public Member Functions | |
SpinLock () | |
Construct a new lock. | |
~SpinLock () | |
Destruct the lock. | |
void | set () |
Acquire the lock exclusively. | |
void | unset () |
Release an exclusive lock. | |
bool | trySet () |
Attempt to acquire the lock exclusively. | |
void | setRead () |
Acquire the lock shared with other readers. | |
void | unsetRead () |
Release a shared read lock. | |
bool | trySetRead () |
Attempt to acquire the lock shared with other readers. | |
bool | isSet () |
Test if the lock is set. | |
bool | isSetWrite () |
Test if the lock is set exclusively. | |
bool | isSetRead () |
Test if the lock is set shared. |
A fast lock for uncontended memory access.
If Thread::yield does not work like expected, priority inversion is possible. If used as a read-write lock, readers or writers will starve on high contention.
Definition at line 38 of file spinLock.h.
Construct a new lock.
Destruct the lock.
bool lunchbox::SpinLock::isSet | ( | ) |
Test if the lock is set.
bool lunchbox::SpinLock::isSetRead | ( | ) |
Test if the lock is set shared.
bool lunchbox::SpinLock::isSetWrite | ( | ) |
Test if the lock is set exclusively.
void lunchbox::SpinLock::set | ( | ) |
Acquire the lock exclusively.
void lunchbox::SpinLock::setRead | ( | ) |
Acquire the lock shared with other readers.
bool lunchbox::SpinLock::trySet | ( | ) |
Attempt to acquire the lock exclusively.
bool lunchbox::SpinLock::trySetRead | ( | ) |
Attempt to acquire the lock shared with other readers.
void lunchbox::SpinLock::unset | ( | ) |
Release an exclusive lock.
void lunchbox::SpinLock::unsetRead | ( | ) |
Release a shared read lock.