From 1d94a6893689ad1fb8e06308ae51603a6c8708a8 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sun, 20 Dec 2020 15:37:58 -0700 Subject: add an option to compile zig in single-threaded mode And enable it for Drone CI. I hate to do this, but I need to make progress on other fronts. --- src/ThreadPool.zig | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/ThreadPool.zig') 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, -- cgit v1.2.3