authorgravatar for topolarity@tapscott.meCody Tapscott <topolarity@tapscott.me> 2022-06-10 07:21:54-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-06-10 21:59:39-04:00
log9b05474d797ea4600dbae36ae95d9eb042040bb2
tree0ef7792ba1ca44026a287ec2360e61b4268f0b39
parent62023c60b4809aee5b23a62c70927075fcce3375

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.

1 files changed, 4 insertions(+), 0 deletions(-)

src/ThreadPool.zig+4
...@@ -49,6 +49,10 @@ pub fn deinit(self: *ThreadPool) void {...@@ -49,6 +49,10 @@ pub fn deinit(self: *ThreadPool) void {
49}49}
5050
51fn join(self: *ThreadPool, spawned: usize) void {51fn join(self: *ThreadPool, spawned: usize) void {
52 if (builtin.single_threaded) {
53 return;
54 }
55
52 {56 {
53 self.mutex.lock();57 self.mutex.lock();
54 defer self.mutex.unlock();58 defer self.mutex.unlock();