#include "commons/commons_sync.h" #include "commons/commons_headers_windows.h" // IWYU pragma: keep #include "commons/commons_region_alloc.h" struct _mutex { SRWLOCK handle; }; auto API Mutex_Create(region_alloc& alloc) -> mutex { _mutex& self = RegionAlloc_Alloc<_mutex>(alloc); InitializeSRWLock(&self.handle); return &self; } void API Mutex_Destroy(mutex self) { } void API Mutex_Lock(mutex self) { AcquireSRWLockExclusive(&self->handle); } void API Mutex_Unlock(mutex self) { ReleaseSRWLockExclusive(&self->handle); } struct _condvar { CONDITION_VARIABLE handle; }; auto API CondVar_Create(region_alloc& alloc) -> condvar { _condvar& self = RegionAlloc_Alloc<_condvar>(alloc); InitializeConditionVariable(&self.handle); return &self; } void API CondVar_Destroy(condvar self) { } void API CondVar_Wait(condvar self, mutex mutex) { SleepConditionVariableSRW(&self->handle, &mutex->handle, INFINITE, 0); } void API CondVar_Signal(condvar self) { WakeConditionVariable(&self->handle); }