Base Framework
Public Types | Public Member Functions | List of all members
RecursiveSpinLock Class Reference

Recursive spin lock. More...

#include <base/concurrency/RecursiveSpinLock.h>

Inherits SpinLock.

Public Types

typedef ExclusiveSynchronize< RecursiveSpinLockSync
 
- Public Types inherited from SpinLock
typedef ExclusiveSynchronize< SpinLockSync
 
- Public Types inherited from Lock
typedef ExclusiveSynchronize< LockSync
 

Public Member Functions

 RecursiveSpinLock () noexcept
 
bool isOwner () const noexcept
 
unsigned int getNumberOfLocks () const noexcept
 
void exclusiveLock () const noexcept
 
bool tryExclusiveLock () const noexcept
 
void sharedLock () const noexcept
 
bool trySharedLock () const noexcept
 
void releaseLock () const noexcept
 
- Public Member Functions inherited from SpinLock
 SpinLock () noexcept
 
bool invariant () const noexcept
 
void exclusiveLock () const noexcept
 
bool tryExclusiveLock () const noexcept
 
void sharedLock () const noexcept
 
bool trySharedLock () const noexcept
 
void releaseLock () const noexcept
 
- Public Member Functions inherited from Lock
 Lock () noexcept
 
virtual ~Lock ()
 

Detailed Description

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

Constructor & Destructor Documentation

◆ RecursiveSpinLock()

RecursiveSpinLock::RecursiveSpinLock ( )
noexcept

Initializes the spin lock in unlocked state.

Member Function Documentation

◆ 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.