Fix ThreadPool trueQueueSize

and along the way I also found a task signaling mistake
And I also fixed memory leaks introduced in the previous PR.

fixes #1193
This commit is contained in:
IntegratedQuantum 2025-03-11 21:40:15 +01:00
parent 2e7372580f
commit 4bdf1240b8
2 changed files with 5 additions and 1 deletions

View File

@ -553,6 +553,9 @@ pub fn init() void {
}
pub fn reset() void {
for(models.items) |model| {
model.deinit();
}
models.clearRetainingCapacity();
quads.clearRetainingCapacity();
extraQuadInfos.clearRetainingCapacity();

View File

@ -538,7 +538,7 @@ pub fn BlockingMaxHeap(comptime T: type) type { // MARK: BlockingMaxHeap
self.size += 1;
}
self.waitingThreads.signal();
self.waitingThreads.broadcast();
}
fn removeIndex(self: *@This(), i: usize) void {
@ -758,6 +758,7 @@ pub const ThreadPool = struct { // MARK: ThreadPool
for(self.loadList.array[0..self.loadList.size]) |task| {
task.vtable.clean(task.self);
}
_ = self.trueQueueSize.fetchSub(self.loadList.size, .monotonic);
self.loadList.size = 0;
self.loadList.mutex.unlock();
// Wait for the in-progress tasks to finish: