| 95 | }; |
| 96 | |
| 97 | class Spinlock |
| 98 | { |
| 99 | public: |
| 100 | |
| 101 | void lock() |
| 102 | { |
| 103 | while (m_lock.test_and_set(std::memory_order_acquire)); |
| 104 | } |
| 105 | |
| 106 | void unlock() |
| 107 | { |
| 108 | m_lock.clear(std::memory_order_release); |
| 109 | } |
| 110 | |
| 111 | Spinlock() = default; |
| 112 | Spinlock(Spinlock const& other) {}; |
| 113 | Spinlock& operator=(Spinlock const& other) { return *this; } |
| 114 | |
| 115 | |
| 116 | private: |
| 117 | |
| 118 | std::atomic_flag m_lock = ATOMIC_FLAG_INIT; |
| 119 | }; |
| 120 | } |
| 121 | |
| 122 | #endif // __DATA_STRUCTURES_H__ |
nothing calls this directly
no outgoing calls
no test coverage detected