10 using std::atomic_flag;
37 if (
locked.test_and_set(std::memory_order_acquire) ==
false)
return true;
45 while (
locked.test_and_set(std::memory_order_acquire));
52 locked.clear(std::memory_order_release);
57 atomic_flag
locked = ATOMIC_FLAG_INIT;
Spin Lock implementation.
~SpinLock()
Destroys the spin lock.
void unlock()
Unlocks this spin lock.
void lock()
Locks the spin lock, additionally spin lock locks will block until other locks have been unlocked.
bool tryLock()
Tries to locks the spin lock.
#define FORBID_CLASS_COPY(CLASS)