ci skip; start of update to zig 0.16
All checks were successful
Build / build (push) Has been skipped
Test / build_and_test (push) Has been skipped

This commit is contained in:
2026-04-16 22:15:07 +02:00
parent ee0ffbe09d
commit 5be875c07e
15 changed files with 243 additions and 105 deletions

View File

@@ -4,14 +4,18 @@ const Manager = @import("Manager.zig");
const Self = @This();
managers: std.AutoArrayHashMapUnmanaged(std.Thread.Id, Manager),
allocator: std.heap.ThreadSafeAllocator,
mutex: std.Thread.Mutex,
allocator: std.mem.Allocator,
mutex: std.Io.Mutex,
io: std.Io,
pub const init: Self = .{
.managers = .empty,
.allocator = .{ .child_allocator = std.heap.c_allocator },
.mutex = .{},
};
pub fn init(io: std.Io, allocator: std.mem.Allocator) Self {
return .{
.managers = .empty,
.allocator = allocator,
.mutex = .init,
.io = io,
};
}
pub fn get(self: *Self) *Manager {
const allocator = self.allocator.allocator();
@@ -23,17 +27,14 @@ pub fn get(self: *Self) *Manager {
}
pub fn deinit(self: *Self) void {
{
self.mutex.lock();
defer self.mutex.unlock();
self.mutex.lockUncancelable();
defer self.mutex.unlock();
if (self.managers.getPtr(std.Thread.getCurrentId())) |manager| {
manager.deinit();
_ = self.managers.orderedRemove(std.Thread.getCurrentId());
}
if (self.managers.getPtr(std.Thread.getCurrentId())) |manager| {
manager.deinit();
_ = self.managers.orderedRemove(std.Thread.getCurrentId());
}
if (self.managers.count() == 0) {
self.managers.deinit(self.allocator.allocator());
self.* = .init;
self.managers.deinit(self.allocator);
}
}