Spin lock (non-inlined)
More...
#include <base/concurrency/NISpinLock.h>
Inherits Lock.
Spin lock (non-inlined)
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 SpinLock
- Version
- 1.0
◆ NISpinLock()
NISpinLock::NISpinLock |
( |
| ) |
|
|
noexcept |
Initializes spin lock to unlocked state.
◆ exclusiveLock()
void NISpinLock::exclusiveLock |
( |
| ) |
const |
|
virtualnoexcept |
Acquires an exclusive lock.
Implements Lock.
◆ releaseLock()
void NISpinLock::releaseLock |
( |
| ) |
const |
|
virtualnoexcept |
Releases the spin lock.
Implements Lock.
◆ sharedLock()
void NISpinLock::sharedLock |
( |
| ) |
const |
|
inlinevirtualnoexcept |
Acquires a shared lock. For some lock implementations this will acquire an exclusive lock.
Implements Lock.
◆ tryExclusiveLock()
bool NISpinLock::tryExclusiveLock |
( |
| ) |
const |
|
virtualnoexcept |
Tries to acquire an exclusive lock.
- Returns
- True on success.
Implements Lock.
◆ trySharedLock()
bool NISpinLock::trySharedLock |
( |
| ) |
const |
|
inlinevirtualnoexcept |
Tries to acquire a shared lock. acquire an exclusive lock.
- Returns
- True on success.
Implements Lock.