- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
class SpinLock
{
std::atomic_flag lck;
public:
SpinLock(){
unlock();
}
__forceinline void lock(){
while (lck.test_and_set(std::memory_order_acquire)){
}
}
__forceinline void unlock(){
lck.clear(std::memory_order_release);
}
};