MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/CompactNSearch / Spinlock

Class Spinlock

include/DataStructures.h:97–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95};
96
97class Spinlock
98{
99public:
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
116private:
117
118 std::atomic_flag m_lock = ATOMIC_FLAG_INIT;
119};
120}
121
122#endif // __DATA_STRUCTURES_H__

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected