switching from EnterCriticalSection to TryEnterCriticalSection

master
emekoi 2018-11-18 01:15:24 -06:00
parent 99f44219bc
commit aaae2f5705
2 changed files with 2 additions and 2 deletions

View File

@ -96,7 +96,7 @@ const MutexWindows = struct {
pub fn acquire(self: *Mutex) Held {
self.initOsData();
windows.EnterCriticalSection(&self.lock);
while (windows.TryEnterCriticalSection(&self.lock) == 0) {}
return Held { .mutex = self };
}
};

View File

@ -222,7 +222,7 @@ pub const FOREGROUND_RED = 4;
pub const FOREGROUND_INTENSITY = 8;
pub extern "kernel32" stdcallcc fn InitializeCriticalSection(lpCriticalSection: *?RTL_CRITICAL_SECTION) void;
pub extern "kernel32" stdcallcc fn EnterCriticalSection(lpCriticalSection: *?RTL_CRITICAL_SECTION) void;
pub extern "kernel32" stdcallcc fn TryEnterCriticalSection(lpCriticalSection: *?RTL_CRITICAL_SECTION) BOOL;
pub extern "kernel32" stdcallcc fn LeaveCriticalSection(lpCriticalSection: *?RTL_CRITICAL_SECTION) void;
pub extern "kernel32" stdcallcc fn DeleteCriticalSection(lpCriticalSection: *?RTL_CRITICAL_SECTION) void;