BitShares-Core  5.0.0
BitShares blockchain implementation and command-line interface 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

fc::spin_lock::spin_lock ( )

Definition at line 9 of file spin_lock.cpp.

Member Function Documentation

void fc::spin_lock::lock ( )

Definition at line 34 of file spin_lock.cpp.

bool fc::spin_lock::try_lock ( )

Definition at line 17 of file spin_lock.cpp.

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

Definition at line 22 of file spin_lock.cpp.

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

Definition at line 26 of file spin_lock.cpp.

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: