|
Equalizer
1.2.1
|
A fast lock for uncontended memory access. More...
#include <spinLock.h>
Inheritance diagram for co::base::SpinLock:
Collaboration diagram for co::base::SpinLock: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.
| co::base::SpinLock::SpinLock | ( | ) | [inline] |
| co::base::SpinLock::~SpinLock | ( | ) | [inline] |
| bool co::base::SpinLock::isSet | ( | ) | [inline] |
Test if the lock is set.
Definition at line 136 of file spinLock.h.
| bool co::base::SpinLock::isSetRead | ( | ) | [inline] |
Test if the lock is set shared.
Definition at line 152 of file spinLock.h.
Referenced by trySetRead().
Here is the caller graph for this function:| bool co::base::SpinLock::isSetWrite | ( | ) | [inline] |
Test if the lock is set exclusively.
Definition at line 144 of file spinLock.h.
Referenced by trySet().
Here is the caller graph for this function:| void co::base::SpinLock::set | ( | ) | [inline] |
Acquire the lock exclusively.
Definition at line 51 of file spinLock.h.
References trySet().
Here is the call graph for this function:| void co::base::SpinLock::setRead | ( | ) | [inline] |
Acquire the lock shared with other readers.
Definition at line 84 of file spinLock.h.
References trySetRead().
Here is the call graph for this function:| bool co::base::SpinLock::trySet | ( | ) | [inline] |
Attempt to acquire the lock exclusively.
Definition at line 75 of file spinLock.h.
References co::base::Atomic< T >::compareAndSwap(), and isSetWrite().
Referenced by set().
Here is the call graph for this function:
Here is the caller graph for this function:| bool co::base::SpinLock::trySetRead | ( | ) | [inline] |
Attempt to acquire the lock shared with other readers.
Definition at line 114 of file spinLock.h.
References co::base::Atomic< T >::compareAndSwap(), isSetRead(), and co::base::memoryBarrier().
Referenced by setRead().
Here is the call graph for this function:
Here is the caller graph for this function:| void co::base::SpinLock::unset | ( | ) | [inline] |
| void co::base::SpinLock::unsetRead | ( | ) | [inline] |
Release a shared read lock.
Definition at line 95 of file spinLock.h.
References co::base::Atomic< T >::compareAndSwap(), and co::base::memoryBarrier().
Here is the call graph for this function:
1.2.1 by
1.8.0