InternPool: temporarily disable multi-threaded behavior

This reduces the cost of the new data structure until the multi-threaded
behavior is actually used.
This commit is contained in:
Jacob Young
2024-07-05 13:34:14 -04:00
parent 92ddb959a7
commit 383cffbfae
3 changed files with 67 additions and 41 deletions

View File

@@ -8,8 +8,13 @@ cond: std.Thread.Condition = .{},
run_queue: RunQueue = .{},
is_running: bool = true,
allocator: std.mem.Allocator,
threads: []std.Thread,
ids: std.AutoArrayHashMapUnmanaged(std.Thread.Id, void),
threads: if (builtin.single_threaded) [0]std.Thread else []std.Thread,
ids: if (builtin.single_threaded) struct {
inline fn deinit(_: @This(), _: std.mem.Allocator) void {}
fn getIndex(_: @This(), _: std.Thread.Id) usize {
return 0;
}
} else std.AutoArrayHashMapUnmanaged(std.Thread.Id, void),
const RunQueue = std.SinglyLinkedList(Runnable);
const Runnable = struct {
@@ -29,7 +34,7 @@ pub fn init(pool: *Pool, options: Options) !void {
pool.* = .{
.allocator = allocator,
.threads = &[_]std.Thread{},
.threads = if (builtin.single_threaded) .{} else &.{},
.ids = .{},
};