diff options
| author | emekoi <emekankurumeh@outlook.com> | 2018-11-18 18:32:50 -0600 |
|---|---|---|
| committer | emekoi <emekankurumeh@outlook.com> | 2019-01-11 09:56:34 -0600 |
| commit | 25d7f5b65475d087ee1f046a364f8a9e6cd60135 (patch) | |
| tree | 34b817b0876cbb9e9ba4575a398d0415b777827e /std/mutex.zig | |
| parent | aaae2f5705a2dee3a12ea49c1094c217a73bb897 (diff) | |
| download | zig-25d7f5b65475d087ee1f046a364f8a9e6cd60135.tar.gz zig-25d7f5b65475d087ee1f046a364f8a9e6cd60135.zip | |
switching back to EnterCriticalSection
Diffstat (limited to 'std/mutex.zig')
| -rw-r--r-- | std/mutex.zig | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/std/mutex.zig b/std/mutex.zig index c0b5d3b002..01ff891b80 100644 --- a/std/mutex.zig +++ b/std/mutex.zig @@ -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 }; } }; |
