diff options
author | 2022-07-07 03:52:24 +0300 | |
---|---|---|
committer | 2022-07-06 19:22:29 -0700 | |
commit | ee5144924b68a14293b4628476e438ab6b7b84ed (patch) | |
tree | b8298e43865ce3658311c2b367b37727492eedf8 | |
parent | 57f2208bdf2bea06062ef016e0ea832d4eeb29f0 (diff) | |
download | bun-ee5144924b68a14293b4628476e438ab6b7b84ed.tar.gz bun-ee5144924b68a14293b4628476e438ab6b7b84ed.tar.zst bun-ee5144924b68a14293b4628476e438ab6b7b84ed.zip |
fix: spawn thread on linux
Diffstat (limited to '')
-rw-r--r-- | src/thread_pool.zig | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/thread_pool.zig b/src/thread_pool.zig index 9608c1bca..514225d98 100644 --- a/src/thread_pool.zig +++ b/src/thread_pool.zig @@ -2,10 +2,12 @@ // https://github.com/kprotty/zap/blob/blog/src/thread_pool.zig const std = @import("std"); +const bun = @import("./global.zig"); const ThreadPool = @This(); const Futex = @import("./futex.zig"); const AsyncIO = @import("io"); +const Environment = bun.Environment; const assert = std.debug.assert; const Atomic = std.atomic.Atomic; pub const OnSpawnCallback = fn (ctx: ?*anyopaque) ?*anyopaque; @@ -182,11 +184,12 @@ noinline fn notifySlow(self: *ThreadPool, is_waking: bool) void { // We signaled to spawn a new thread if (can_wake and sync.spawned < self.max_threads) { - const spawn_config = std.Thread.SpawnConfig{ + const spawn_config = std.Thread.SpawnConfig{}; + if (Environment.isMac) { // stack size must be a multiple of page_size // macOS will fail to spawn a thread if the stack size is not a multiple of page_size - .stack_size = ((self.stack_size + (std.mem.page_size / 2)) / std.mem.page_size) * std.mem.page_size, - }; + spawn_config.stack_size = ((self.stack_size + (std.mem.page_size / 2)) / std.mem.page_size) * std.mem.page_size; + } const thread = std.Thread.spawn(spawn_config, Thread.run, .{self}) catch return self.unregister(null); // if (self.name.len > 0) thread.setName(self.name) catch {}; return thread.detach(); |