#ifndef PLS_SPINLOCK_H #define PLS_SPINLOCK_H #include #include #include "pls/internal/base/thread.h" namespace pls { namespace internal { namespace base { class spin_lock { std::atomic_flag flag_; int yield_at_tries_; public: spin_lock(): flag_{ATOMIC_FLAG_INIT}, yield_at_tries_{1024} {}; spin_lock(const spin_lock& other): flag_{ATOMIC_FLAG_INIT}, yield_at_tries_{other.yield_at_tries_} { std::cout << "Spinlock Moved!" << std::endl; } void lock(); void unlock(); }; } } } #endif //PLS_SPINLOCK_H