/* * Spinlock_mutex.hh * * Created on: 22 ���. 2020 �. * Author: _aam */ #pragma once #include namespace logging { class SpinlockMutex { std::atomic_flag spinlock_flag; unsigned long tick_tok; public: SpinlockMutex() : tick_tok(0) { spinlock_flag.clear(); }; ~SpinlockMutex() { unlock(); } void lock() { while( spinlock_flag.test_and_set(std::memory_order_acquire) ) tick_tok++; } void unlock() { spinlock_flag.clear(std::memory_order_release); }; }; }