Commit 9b05474d79

Cody Tapscott <topolarity@tapscott.me>
2022-06-10 16:21:54
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 parent 62023c6
Changed files (1)
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();