diff options
Diffstat (limited to 'src/thread_pool.zig')
-rw-r--r-- | src/thread_pool.zig | 27 |
1 files changed, 2 insertions, 25 deletions
diff --git a/src/thread_pool.zig b/src/thread_pool.zig index 3c56da4b1..3cfc02979 100644 --- a/src/thread_pool.zig +++ b/src/thread_pool.zig @@ -2,17 +2,15 @@ // https://github.com/kprotty/zap/blob/blog/src/thread_pool.zig const std = @import("std"); -const bun = @import("./global.zig"); +const bun = @import("bun"); 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; -io: ?*AsyncIO = null, sleep_on_idle_network_thread: bool = true, /// executed on the thread on_thread_spawn: ?OnSpawnCallback = null, @@ -250,18 +248,8 @@ noinline fn wait(self: *ThreadPool, _is_waking: bool) error{Shutdown}!bool { .Acquire, .Monotonic, ) orelse { - if (self.io) |io| { - io.tick() catch {}; - } - return is_waking or (sync.state == .signaled); }); - - // No notification to consume. - // Mark this thread as idle before sleeping on the idle_event. - if (self.io) |io| { - io.tick() catch {}; - } } else if (!is_idle) { var new_sync = sync; new_sync.idle += 1; @@ -278,12 +266,6 @@ noinline fn wait(self: *ThreadPool, _is_waking: bool) error{Shutdown}!bool { is_idle = true; continue; }); - - // Wait for a signal by either notify() or shutdown() without wasting cpu cycles. - // TODO: Add I/O polling here. - if (self.io) |io| { - io.tick() catch {}; - } } else { self.idle_event.wait(); sync = @bitCast(Sync, self.sync.load(.Monotonic)); @@ -369,7 +351,7 @@ fn join(self: *ThreadPool) void { thread.join_event.notify(); } -const Output = @import("./global.zig").Output; +const Output = @import("bun").Output; pub const Thread = struct { next: ?*Thread = null, @@ -433,11 +415,6 @@ pub const Thread = struct { return stole; } - // TODO: add optimistic I/O polling here - if (thread_pool.io) |io| { - io.tick() catch {}; - } - // Then try work stealing from other threads var num_threads: u32 = @bitCast(Sync, thread_pool.sync.load(.Monotonic)).spawned; while (num_threads > 0) : (num_threads -= 1) { |