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.
This commit is contained in:
Cody Tapscott authored and Andrew Kelley committed 2022-06-10 21:59:39 -04:00
1 parent 62023c60b4
commit 9b05474d79
1 file changed
+4
+4
View File
@@ -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();