switching back to EnterCriticalSection
parent
aaae2f5705
commit
25d7f5b654
|
@ -77,12 +77,6 @@ const MutexWindows = struct {
|
|||
}
|
||||
};
|
||||
|
||||
fn initOsData(self: *MutexWindows) void {
|
||||
if (self.lock == null) {
|
||||
windows.InitializeCriticalSection(&self.lock);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn init() Mutex {
|
||||
return Mutex {
|
||||
.lock = null,
|
||||
|
@ -95,8 +89,11 @@ const MutexWindows = struct {
|
|||
}
|
||||
|
||||
pub fn acquire(self: *Mutex) Held {
|
||||
self.initOsData();
|
||||
while (windows.TryEnterCriticalSection(&self.lock) == 0) {}
|
||||
if (self.lock == null) {
|
||||
windows.InitializeCriticalSection(&self.lock);
|
||||
}
|
||||
|
||||
windows.EnterCriticalSection(&self.lock);
|
||||
return Held { .mutex = self };
|
||||
}
|
||||
};
|
||||
|
|
|
@ -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 TryEnterCriticalSection(lpCriticalSection: *?RTL_CRITICAL_SECTION) BOOL;
|
||||
pub extern "kernel32" stdcallcc fn EnterCriticalSection(lpCriticalSection: *?RTL_CRITICAL_SECTION) void;
|
||||
pub extern "kernel32" stdcallcc fn LeaveCriticalSection(lpCriticalSection: *?RTL_CRITICAL_SECTION) void;
|
||||
pub extern "kernel32" stdcallcc fn DeleteCriticalSection(lpCriticalSection: *?RTL_CRITICAL_SECTION) void;
|
||||
|
||||
|
|
Loading…
Reference in New Issue