|
Lunchbox
1.16.0
Multi-threaded C++ toolbox library for all application developers creating high-performance multi-threaded programs.
|
A fast lock for uncontended memory access. More...
#include <spinLock.h>
Inheritance diagram for lunchbox::SpinLock:
Collaboration diagram for lunchbox::SpinLock:Public Member Functions | |
| SpinLock () | |
| Construct a new lock. More... | |
| ~SpinLock () | |
| Destruct the lock. More... | |
| void | set () |
| Acquire the lock exclusively. More... | |
| void | lock () |
| void | unset () |
| Release an exclusive lock. More... | |
| void | unlock () |
| bool | trySet () |
| Attempt to acquire the lock exclusively. More... | |
| void | setRead () |
| Acquire the lock shared with other readers. More... | |
| void | lock_shared () |
| void | unsetRead () |
| Release a shared read lock. More... | |
| void | unlock_shared () |
| bool | trySetRead () |
| Attempt to acquire the lock shared with other readers. More... | |
| bool | isSet () |
| Test if the lock is set. More... | |
| bool | isSetWrite () |
| Test if the lock is set exclusively. More... | |
| 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::SpinLock::SpinLock | ( | ) |
Construct a new lock.
| lunchbox::SpinLock::~SpinLock | ( | ) |
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.
Referenced by lunchbox::LFVector< T, nSlots >::getWriteLock().
Here is the caller graph for this function:| 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.