stk-code_catmod/lib/graphics_engine/include/ge_spin_lock.hpp

15 lines
361 B
C++
Raw Normal View History

#ifndef HEADER_GE_SPIN_LOCK_HPP
#define HEADER_GE_SPIN_LOCK_HPP
#include <atomic>
class GESpinLock
{
mutable std::atomic_flag m_locked = ATOMIC_FLAG_INIT;
public:
void lock() const
{ while (m_locked.test_and_set(std::memory_order_acquire)); }
void unlock() const { m_locked.clear(std::memory_order_release); }
};
#endif