pureikyubu/SRC/Common/Spinlock.cpp
2020-08-06 22:18:38 +03:00

21 lines
273 B
C++

#include "pch.h"
#ifdef _WINDOWS
void SpinLock::Lock()
{
while (_InterlockedCompareExchange(&_lock,
1, // exchange
0) // comparand
== 1)
{
// spin!
}
}
void SpinLock::Unlock()
{
_InterlockedExchange(&_lock, 0);
}
#endif