commit 9e1aeda3bf6e379ef8572d92eca1644175ef69f5 (tree)
parent 9698ea3173351a66de8950c5124f22e80f6c9fc8
Author: Andrew Kelley <andrew@ziglang.org>
Date: Thu, 14 Jan 2021 21:34:30 -0700
std.Thread.StaticResetEvent: call spinLoopHint appropriately
Diffstat:
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/lib/std/Thread/StaticResetEvent.zig b/lib/std/Thread/StaticResetEvent.zig
@@ -15,7 +15,6 @@
const std = @import("../std.zig");
const StaticResetEvent = @This();
-const SpinLock = std.SpinLock;
const assert = std.debug.assert;
const os = std.os;
const time = std.time;
@@ -183,7 +182,7 @@ pub const AtomicEvent = struct {
timer = time.Timer.start() catch return error.TimedOut;
while (@atomicLoad(u32, waiters, .Acquire) != WAKE) {
- SpinLock.yield();
+ std.os.sched_yield() catch std.Thread.spinLoopHint();
if (timeout) |timeout_ns| {
if (timer.read() >= timeout_ns)
return error.TimedOut;
@@ -294,7 +293,7 @@ pub const AtomicEvent = struct {
return @intToPtr(?windows.HANDLE, handle);
},
LOADING => {
- SpinLock.yield();
+ std.os.sched_yield() catch std.Thread.spinLoopHint();
handle = @atomicLoad(usize, &event_handle, .Monotonic);
},
else => {