Spin lock (fast).
More...
#include <base/concurrency/SpinLock.h>
Inherits Lock.
Inherited by RecursiveSpinLock.
Spin lock (fast).
Spin lock is a synchronization object just like MutualExclusion. SpinLock does not use any operating system resources. The SpinLock is fast. The CPU cannot do anything useful while waiting for a spin lock to be released.
- See also
- MutualExclusion NISpinLock
- Version
- 1.2
- Examples
- testsuite/Thread.cpp.
◆ SpinLock()
Initializes spin lock to unlocked state.
◆ exclusiveLock()
void SpinLock::exclusiveLock |
( |
| ) |
const |
|
virtualnoexcept |
Acquires an exclusive lock.
Implements Lock.
◆ invariant()
bool SpinLock::invariant |
( |
| ) |
const |
|
noexcept |
Returns true if state is valid.
◆ releaseLock()
void SpinLock::releaseLock |
( |
| ) |
const |
|
virtualnoexcept |
Releases the spin lock.
Implements Lock.
◆ sharedLock()
void SpinLock::sharedLock |
( |
| ) |
const |
|
inlinevirtualnoexcept |
Acquires a shared lock. For some lock implementations this will acquire an exclusive lock.
Implements Lock.
◆ tryExclusiveLock()
bool SpinLock::tryExclusiveLock |
( |
| ) |
const |
|
virtualnoexcept |
Tries to acquire an exclusive lock.
- Returns
- True on success.
Implements Lock.
◆ trySharedLock()
bool SpinLock::trySharedLock |
( |
| ) |
const |
|
inlinevirtualnoexcept |
Tries to acquire a shared lock. acquire an exclusive lock.
- Returns
- True on success.
Implements Lock.