diff options
| author | Cody Tapscott <topolarity@tapscott.me> | 2022-06-10 07:21:54 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-06-10 21:59:39 -0400 |
| commit | 9b05474d797ea4600dbae36ae95d9eb042040bb2 (patch) | |
| tree | 0ef7792ba1ca44026a287ec2360e61b4268f0b39 /src | |
| parent | 62023c60b4809aee5b23a62c70927075fcce3375 (diff) | |
| download | zig-9b05474d797ea4600dbae36ae95d9eb042040bb2.tar.gz zig-9b05474d797ea4600dbae36ae95d9eb042040bb2.zip | |
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 (limited to 'src')
| -rw-r--r-- | src/ThreadPool.zig | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/ThreadPool.zig b/src/ThreadPool.zig index 7d1c8420af..55e40ea287 100644 --- 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(); |
