authorgravatar for emekankurumeh@outlook.comemekoi <emekankurumeh@outlook.com> 2018-11-18 18:32:50-06:00
committergravatar for emekankurumeh@outlook.comemekoi <emekankurumeh@outlook.com> 2019-01-11 09:56:34-06:00
log25d7f5b65475d087ee1f046a364f8a9e6cd60135
tree34b817b0876cbb9e9ba4575a398d0415b777827e
parentaaae2f5705a2dee3a12ea49c1094c217a73bb897

switching back to EnterCriticalSection


2 files changed, 6 insertions(+), 9 deletions(-)

std/mutex.zig+5-8
......@@ -77,12 +77,6 @@ const MutexWindows = struct {
7777 }
7878 };
7979
80 fn initOsData(self: *MutexWindows) void {
81 if (self.lock == null) {
82 windows.InitializeCriticalSection(&self.lock);
83 }
84 }
85
8680 pub fn init() Mutex {
8781 return Mutex {
8882 .lock = null,
......@@ -95,8 +89,11 @@ const MutexWindows = struct {
9589 }
9690
9791 pub fn acquire(self: *Mutex) Held {
98 self.initOsData();
99 while (windows.TryEnterCriticalSection(&self.lock) == 0) {}
92 if (self.lock == null) {
93 windows.InitializeCriticalSection(&self.lock);
94 }
95
96 windows.EnterCriticalSection(&self.lock);
10097 return Held { .mutex = self };
10198 }
10299};
std/os/windows/kernel32.zig+1-1
......@@ -222,7 +222,7 @@ pub const FOREGROUND_RED = 4;
222222pub const FOREGROUND_INTENSITY = 8;
223223
224224pub extern "kernel32" stdcallcc fn InitializeCriticalSection(lpCriticalSection: *?RTL_CRITICAL_SECTION) void;
225pub extern "kernel32" stdcallcc fn TryEnterCriticalSection(lpCriticalSection: *?RTL_CRITICAL_SECTION) BOOL;
225pub extern "kernel32" stdcallcc fn EnterCriticalSection(lpCriticalSection: *?RTL_CRITICAL_SECTION) void;
226226pub extern "kernel32" stdcallcc fn LeaveCriticalSection(lpCriticalSection: *?RTL_CRITICAL_SECTION) void;
227227pub extern "kernel32" stdcallcc fn DeleteCriticalSection(lpCriticalSection: *?RTL_CRITICAL_SECTION) void;
228228