Recursive spin lock.
More...
#include <base/concurrency/RecursiveSpinLock.h>
Inherits SpinLock.
Recursive spin lock.
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
◆ RecursiveSpinLock()
RecursiveSpinLock::RecursiveSpinLock |
( |
| ) |
|
|
noexcept |
Initializes the spin lock in unlocked state.
◆ exclusiveLock()
void RecursiveSpinLock::exclusiveLock |
( |
| ) |
const |
|
virtualnoexcept |
Acquires an exclusive lock.
Implements Lock.
◆ getNumberOfLocks()
unsigned int RecursiveSpinLock::getNumberOfLocks |
( |
| ) |
const |
|
inlinenoexcept |
Returns the number of locks currently held by the owner of the lock. Garbage is returned unless the executing thread is the owner.
◆ isOwner()
bool RecursiveSpinLock::isOwner |
( |
| ) |
const |
|
inlinenoexcept |
Returns true if the executing thread is the owner of the lock.
◆ releaseLock()
void RecursiveSpinLock::releaseLock |
( |
| ) |
const |
|
virtualnoexcept |
Releases the spin lock.
Implements Lock.
◆ sharedLock()
void RecursiveSpinLock::sharedLock |
( |
| ) |
const |
|
inlinevirtualnoexcept |
Acquires a shared lock. For some lock implementations this will acquire an exclusive lock.
Implements Lock.
◆ tryExclusiveLock()
bool RecursiveSpinLock::tryExclusiveLock |
( |
| ) |
const |
|
virtualnoexcept |
Tries to acquire an exclusive lock. Guaranteed to succeed if the executing thread already has ownership.
- Returns
- True on success.
Implements Lock.
◆ trySharedLock()
bool RecursiveSpinLock::trySharedLock |
( |
| ) |
const |
|
inlinevirtualnoexcept |
Tries to acquire a shared lock. acquire an exclusive lock.
- Returns
- True on success.
Implements Lock.