123456789101112131415161718192021222324 |
- #ifndef CORE_SPIN_LOCK_HPP
- #define CORE_SPIN_LOCK_HPP
- // stdatomic.h is not compatible with C++
- // all calls are noexcept
- #include <atomic>
- using atomic_bool = std::atomic_bool;
- namespace Core {
- class SpinLock final {
- atomic_bool locked;
- public:
- SpinLock();
- SpinLock(const SpinLock& other) = delete;
- SpinLock(SpinLock&& other) = delete;
- SpinLock& operator=(const SpinLock& other) = delete;
- SpinLock& operator=(SpinLock&& other) = delete;
- void lock();
- void unlock();
- };
- }
- #endif
|