BitShares-Core
7.0.2
BitShares blockchain node software and command-line wallet software
|
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 () |
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.
fc::spin_lock::spin_lock | ( | ) |
Definition at line 9 of file spin_lock.cpp.
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.