BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
Public Member Functions | List of all members
fc::spin_lock Class Reference

modified spin-lock that yields on failure, but becomes a 'spin lock' if there are no other tasks to yield to. More...

#include <spin_lock.hpp>

Public Member Functions

 spin_lock ()
 
bool try_lock ()
 
bool try_lock_for (const microseconds &rel_time)
 
bool try_lock_until (const time_point &abs_time)
 
void lock ()
 
void unlock ()
 

Detailed Description

modified spin-lock that yields on failure, but becomes a 'spin lock' if there are no other tasks to yield to.

This kind of lock is lighter weight than a full mutex, but potentially slower than a staight spin_lock.

This spin_lock does not block the current thread, but instead attempts to use an atomic operation to aquire the lock. If unsuccessful, then it yields to other tasks before trying again. If there are no other tasks then yield is a no-op and spin_lock becomes a spin-lock.

Definition at line 20 of file spin_lock.hpp.

Constructor & Destructor Documentation

◆ spin_lock()

fc::spin_lock::spin_lock ( )

Definition at line 9 of file spin_lock.cpp.

Member Function Documentation

◆ lock()

void fc::spin_lock::lock ( )

Definition at line 34 of file spin_lock.cpp.

◆ try_lock()

bool fc::spin_lock::try_lock ( )

Definition at line 17 of file spin_lock.cpp.

◆ try_lock_for()

bool fc::spin_lock::try_lock_for ( const microseconds rel_time)

Definition at line 22 of file spin_lock.cpp.

◆ try_lock_until()

bool fc::spin_lock::try_lock_until ( const time_point abs_time)

Definition at line 26 of file spin_lock.cpp.

◆ unlock()

void fc::spin_lock::unlock ( )

Definition at line 39 of file spin_lock.cpp.


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