From 9e1aeda3bf6e379ef8572d92eca1644175ef69f5 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 14 Jan 2021 21:34:30 -0700 Subject: [PATCH] std.Thread.StaticResetEvent: call spinLoopHint appropriately --- lib/std/Thread/StaticResetEvent.zig | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/std/Thread/StaticResetEvent.zig b/lib/std/Thread/StaticResetEvent.zig index 414583e477..6d90d7cf9a 100644 --- 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 => {