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.
This commit is contained in:
Andrew Kelley
2020-12-20 15:37:58 -07:00
parent 10d30838d1
commit 1d94a68936
5 changed files with 29 additions and 6 deletions

View File

@@ -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,