aboutsummaryrefslogtreecommitdiff
path: root/lib/std/event/loop.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-01-11 22:23:03 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-01-11 22:23:03 -0700
commit8ea2b40e5f621482d714fdd7cb05bbc592fc550b (patch)
treed469f4843a89edeff955926f0de9e10e5392792c /lib/std/event/loop.zig
parent0edde40c25c033aec67f235365593ee26ff52740 (diff)
downloadzig-8ea2b40e5f621482d714fdd7cb05bbc592fc550b.tar.gz
zig-8ea2b40e5f621482d714fdd7cb05bbc592fc550b.zip
std.event.Loop: fix race condition when starting the time wheel
closes #7572
Diffstat (limited to 'lib/std/event/loop.zig')
-rw-r--r--lib/std/event/loop.zig3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/std/event/loop.zig b/lib/std/event/loop.zig
index f5df637f37..8101d27a55 100644
--- 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),
};
}