CatapultServer  v0.5.0.1 (Elephant)
catapult::utils::SpinLock Class Reference

Public Member Functions

 SpinLock ()
 Creates an unlocked lock. More...
 
void lock ()
 Blocks until a lock can be obtained for the current execution agent. More...
 
bool try_lock ()
 Attempts to acquire the lock for the current execution agent without blocking. More...
 
void unlock () noexcept
 Releases the lock held by the execution agent. Throws no exceptions. More...
 

Private Attributes

std::atomic_flag m_isLocked
 

Detailed Description

Simple spin lock implemented by using an atomic. Note that function naming allows this to be used as a Lockable type (http://en.cppreference.com/w/cpp/concept/Lockable).

Constructor & Destructor Documentation

◆ SpinLock()

catapult::utils::SpinLock::SpinLock ( )
inline

Creates an unlocked lock.

Here is the call graph for this function:

Member Function Documentation

◆ lock()

void catapult::utils::SpinLock::lock ( )
inline

Blocks until a lock can be obtained for the current execution agent.

Here is the call graph for this function:

◆ try_lock()

bool catapult::utils::SpinLock::try_lock ( )
inline

Attempts to acquire the lock for the current execution agent without blocking.

Here is the caller graph for this function:

◆ unlock()

void catapult::utils::SpinLock::unlock ( )
inlinenoexcept

Releases the lock held by the execution agent. Throws no exceptions.

Here is the caller graph for this function:

Member Data Documentation

◆ m_isLocked

std::atomic_flag catapult::utils::SpinLock::m_isLocked
private

The documentation for this class was generated from the following file: