From d4194c501c08ec1d0d66a13ab41f228e86bdd973 Mon Sep 17 00:00:00 2001 From: Muaz Ahmad Date: Mon, 27 Nov 2023 13:09:02 +0500 Subject: [PATCH] make deallocs not suck since using arena --- src/threads.zig | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/threads.zig b/src/threads.zig index 46e7a07..4a976e1 100644 --- a/src/threads.zig +++ b/src/threads.zig @@ -18,16 +18,13 @@ const QueueWrap = struct { .job_pool = job_pool, }; } - fn deinit(self: *Self) void { - self.job_pool.deinit(); - self.alloc.destroy(self.queue); - } }; pub const ThreadManager = struct { threads: std.ArrayList(std.Thread), arena: std.heap.ArenaAllocator, queue: QueueWrap, + job_pool: util.JobPool, const Self = @This(); @@ -40,13 +37,13 @@ pub const ThreadManager = struct { .threads = std.ArrayList(std.Thread).init(arena_alloc), .arena = arena, .queue = try QueueWrap.init(arena_alloc, job_pool), + .job_pool = job_pool, }; return thread_mgr; } pub fn deinit(self: *Self) void { - self.threads.deinit(); - self.queue.deinit(); self.arena.deinit(); + self.job_pool.deinit(); } };