12 #ifndef ROOT_TSpinMutex
13 #define ROOT_TSpinMutex
45 std::atomic_flag fAFlag = ATOMIC_FLAG_INIT;
48 TSpinMutex() =
default;
49 TSpinMutex(
const TSpinMutex&) =
delete;
50 ~TSpinMutex() =
default;
51 TSpinMutex& operator=(
const TSpinMutex&) =
delete;
53 void lock() {
while (fAFlag.test_and_set(std::memory_order_acquire)); }
54 void unlock() { fAFlag.clear(std::memory_order_release); }
55 bool try_lock() {
return !fAFlag.test_and_set(std::memory_order_acquire); }