mirror of
https://github.com/Karaka-Management/cOMS.git
synced 2026-01-11 11:18:40 +00:00
28 lines
525 B
C++
28 lines
525 B
C++
/**
|
|
* Jingga
|
|
*
|
|
* @copyright Jingga
|
|
* @license OMS License 2.0
|
|
* @version 1.0.0
|
|
* @link https://jingga.app
|
|
*/
|
|
#ifndef TOS_PLATFORM_WIN32_THREADING_SPINLOCK_C
|
|
#define TOS_PLATFORM_WIN32_THREADING_SPINLOCK_C
|
|
|
|
#include <windows.h>
|
|
#include "../TimeUtils.h"
|
|
#include "Spinlock.h"
|
|
|
|
inline
|
|
void spinlock_start(spinlock32* lock, int32 delay = 10) {
|
|
while (InterlockedExchange(lock, 1) != 0) {
|
|
usleep(delay);
|
|
}
|
|
}
|
|
|
|
inline
|
|
void spinlock_end(spinlock32* lock) {
|
|
InterlockedExchange(lock, 0);
|
|
}
|
|
|
|
#endif |