zig

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

commit 9b05474d797ea4600dbae36ae95d9eb042040bb2 (tree)
parent 62023c60b4809aee5b23a62c70927075fcce3375
Author: Cody Tapscott <topolarity@tapscott.me>
Date:   Fri, 10 Jun 2022 07:21:54 -0700

ThreadPool: Make join() a no-op in single-threaded mode

This comptime gate is needed to make sure that purely single-threaded
programs don't generate calls to the std.Thread API.

WASI targets successfully build again with this change.

Diffstat:
Msrc/ThreadPool.zig | 4++++
1 file changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/ThreadPool.zig b/src/ThreadPool.zig @@ -49,6 +49,10 @@ pub fn deinit(self: *ThreadPool) void { } fn join(self: *ThreadPool, spawned: usize) void { + if (builtin.single_threaded) { + return; + } + { self.mutex.lock(); defer self.mutex.unlock();