From c2898c436f0c858d10367b7631091f5a52cce76f Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 18 Oct 2024 22:29:50 -0700 Subject: branch fixes --- src/ThreadSafeQueue.zig | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/ThreadSafeQueue.zig') diff --git a/src/ThreadSafeQueue.zig b/src/ThreadSafeQueue.zig index b014017736..1cf6aaaa3a 100644 --- a/src/ThreadSafeQueue.zig +++ b/src/ThreadSafeQueue.zig @@ -59,5 +59,13 @@ pub fn ThreadSafeQueue(comptime T: type) type { self.state = .run; return was_waiting; } + + /// Safe only to call exactly once when initially starting the worker. + pub fn start(self: *Self) bool { + assert(self.state == .wait); + if (self.shared.items.len == 0) return false; + self.state = .run; + return true; + } }; } -- cgit v1.2.3