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

Spin lock (non-inlined) More...

#include <base/concurrency/NISpinLock.h>

Inherits Lock.

Public Types

typedef ExclusiveSynchronize< NISpinLockSync
 
- Public Types inherited from Lock
typedef ExclusiveSynchronize< LockSync
 

Public Member Functions

 NISpinLock () 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

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

Constructor & Destructor Documentation

◆ NISpinLock()

NISpinLock::NISpinLock ( )
noexcept

Initializes spin lock to unlocked state.

Member Function Documentation

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