aboutsummaryrefslogtreecommitdiff
path: root/src/ThreadPool.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/ThreadPool.zig')
-rw-r--r--src/ThreadPool.zig6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/ThreadPool.zig b/src/ThreadPool.zig
index 7d6af3d24c..00cb26772a 100644
--- a/src/ThreadPool.zig
+++ b/src/ThreadPool.zig
@@ -25,6 +25,8 @@ pub fn init(self: *ThreadPool, allocator: *std.mem.Allocator) !void {
.allocator = allocator,
.threads = &[_]*std.Thread{},
};
+ if (std.builtin.single_threaded)
+ return;
errdefer self.deinit();
@@ -67,6 +69,10 @@ pub fn shutdown(self: *ThreadPool) void {
}
pub fn spawn(self: *ThreadPool, comptime func: anytype, args: anytype) !void {
+ if (std.builtin.single_threaded) {
+ @call(.{}, func, args);
+ return;
+ }
const Args = @TypeOf(args);
const Closure = struct {
arguments: Args,