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_yield_lock.hpp>
Public Member Functions | |
spin_yield_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_yield_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_yield_lock becomes a spin-lock.
Definition at line 20 of file spin_yield_lock.hpp.
fc::spin_yield_lock::spin_yield_lock | ( | ) |
Definition at line 12 of file spin_yield_lock.cpp.
void fc::spin_yield_lock::lock | ( | ) |
Definition at line 38 of file spin_yield_lock.cpp.
bool fc::spin_yield_lock::try_lock | ( | ) |
Definition at line 20 of file spin_yield_lock.cpp.
bool fc::spin_yield_lock::try_lock_for | ( | const microseconds & | rel_time | ) |
Definition at line 25 of file spin_yield_lock.cpp.
bool fc::spin_yield_lock::try_lock_until | ( | const time_point & | abs_time | ) |
Definition at line 29 of file spin_yield_lock.cpp.
void fc::spin_yield_lock::unlock | ( | ) |
Definition at line 45 of file spin_yield_lock.cpp.