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