zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 8ea2b40e5f621482d714fdd7cb05bbc592fc550b (tree)
parent 0edde40c25c033aec67f235365593ee26ff52740
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Mon, 11 Jan 2021 22:23:03 -0700

std.event.Loop: fix race condition when starting the time wheel

closes #7572

Diffstat:
Mlib/std/event/loop.zig | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/lib/std/event/loop.zig b/lib/std/event/loop.zig @@ -796,9 +796,10 @@ pub const Loop = struct { .waiters = DelayQueue.Waiters{ .entries = std.atomic.Queue(anyframe).init(), }, - .thread = try std.Thread.spawn(self, DelayQueue.run), .event = std.AutoResetEvent{}, .is_running = true, + // Must be last so that it can read the other state, such as `is_running`. + .thread = try std.Thread.spawn(self, DelayQueue.run), }; }