feat: things

This commit is contained in:
2025-05-23 13:33:10 +02:00
parent cbeed4003a
commit 33d8306f22
9 changed files with 59 additions and 43 deletions

View File

@@ -36,7 +36,6 @@ pub const Tab = struct {
pub fn setCurrentLocation(self: *Tab, newLocationFullName: models.FullName) !void {
if (self.currentLocation) |c| {
c.item.deinit();
self.allocator.destroy(c);
}
errdefer {
@@ -45,6 +44,9 @@ pub const Tab = struct {
}
const newLocation = try self.rootProvider.getItemByFullName(newLocationFullName, &.{}, self.allocator);
errdefer {
newLocation.deinit();
}
const newLocationContainer = switch (newLocation.item) {
.container => |c| c,
@@ -53,6 +55,7 @@ pub const Tab = struct {
self.currentLocation = newLocationContainer;
self.currentLocationChanged.notify(newLocationContainer);
std.debug.print("\nASD1\n", .{});
//TODO: Proper error handling
std.Thread.Pool.spawn(self.threadPool, loadItemsWrapper, .{ self, newLocationContainer }) catch unreachable;
@@ -68,17 +71,12 @@ pub const Tab = struct {
self.preCurrentItemsUnload.notify(self);
if (self.currentItems.data) |items| {
items.deinit();
}
self.currentItems.data = null;
}
//TODO: half the capacity to prevent "leaking" after a huuuge container has been opened once
_ = self._private.currentItemsAllocator.reset(.retain_capacity);
const arenaAllocator = &self._private.currentItemsAllocator;
const arena = arenaAllocator.allocator();
const arena = self._private.currentItemsAllocator.allocator();
var threadSafeAllocator = std.heap.ThreadSafeAllocator{ .child_allocator = arena };
const allocator = threadSafeAllocator.allocator();
@@ -121,6 +119,7 @@ pub const Tab = struct {
defer self.currentItems.mutex.unlock();
self.currentItemsChanged = true;
}
std.debug.print("\nASDX\n", .{});
}
pub fn deinit(self: *Tab) void {