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,6 +36,8 @@ pub fn preCurrentItemsUnload(ctx: *anyopaque, tab: *Tab) void {
}
pub fn deinit(self: *@This()) void {
self.appState.tabPreCurrentItemsUnload.detach(&self._private.preCurrentItemsUnload);
self.appState.deinit();
self.current_items_allocator.deinit();
}

View File

@@ -10,22 +10,22 @@ pub fn data_loop(vm: *Model) void {
}
vm.usage_number.data -= 1;
}
fn inner_loop(vm: *Model) !void {
const tab = vm.appState.currentTab;
fn inner_loop(appCommonModel: *Model) !void {
const tab = appCommonModel.appState.currentTab;
tab.currentItems.mutex.lock();
defer tab.currentItems.mutex.unlock();
if (tab.currentItemsChanged) {
std.Thread.sleep(10 * std.time.ns_per_ms);
tab.currentItems.mutex.lock();
defer tab.currentItems.mutex.unlock();
if (tab.currentItems.data) |tab_current_items| {
if (tab.currentItems.data) |*tab_current_items| {
{
vm.current_items.mutex.lock();
defer vm.current_items.mutex.unlock();
vm.current_items.data = null;
appCommonModel.current_items.mutex.lock();
defer appCommonModel.current_items.mutex.unlock();
appCommonModel.current_items.data = null;
}
_ = vm.current_items_allocator.reset(.retain_capacity);
const allocator = vm.current_items_allocator.allocator();
_ = appCommonModel.current_items_allocator.reset(.retain_capacity);
const allocator = appCommonModel.current_items_allocator.allocator();
const items = try allocator.alloc(*models.Item, tab_current_items.items.len);
for (tab_current_items.items, 0..) |item, i| {
@@ -40,9 +40,9 @@ fn inner_loop(vm: *Model) !void {
}
}.sort);
vm.current_items.mutex.lock();
defer vm.current_items.mutex.unlock();
vm.current_items.data = items;
appCommonModel.current_items.mutex.lock();
defer appCommonModel.current_items.mutex.unlock();
appCommonModel.current_items.data = items;
tab.currentItemsChanged = false;
}
}