mirror of
https://github.com/PixelGuys/Cubyz.git
synced 2025-08-03 11:17:05 -04:00
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:
parent
2e7372580f
commit
4bdf1240b8
@ -553,6 +553,9 @@ pub fn init() void {
|
||||
}
|
||||
|
||||
pub fn reset() void {
|
||||
for(models.items) |model| {
|
||||
model.deinit();
|
||||
}
|
||||
models.clearRetainingCapacity();
|
||||
quads.clearRetainingCapacity();
|
||||
extraQuadInfos.clearRetainingCapacity();
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user