标签:basic 自旋锁 CQ hang store style code nal let
// Spin lock implementation. // BasicLockable. // Async-signal safe. // unlock() "synchronizes with" lock(). class spinlock { std::atomic<bool> _busy = { false }; public: spinlock() = default; spinlock(const spinlock&) = delete; ~spinlock() { assert(!_busy.load(std::memory_order_relaxed)); } void lock() noexcept { while (_busy.exchange(true, std::memory_order_acquire)) { _mm_pause(); } } void unlock() noexcept { _busy.store(false, std::memory_order_release); } };
标签:basic 自旋锁 CQ hang store style code nal let
原文地址:https://www.cnblogs.com/lenmom/p/9178866.html