Move CFReleaseThread to os package

This commit is contained in:
Mitchell Hashimoto
2024-06-22 20:15:59 -07:00
parent 4aa130b0d1
commit 3038cb4979
3 changed files with 11 additions and 11 deletions

View File

@@ -9,15 +9,15 @@ const builtin = @import("builtin");
const xev = @import("xev");
const macos = @import("macos");
const BlockingQueue = @import("./blocking_queue.zig").BlockingQueue;
const BlockingQueue = @import("../blocking_queue.zig").BlockingQueue;
const Allocator = std.mem.Allocator;
const log = std.log.scoped(.cf_release_thread);
pub const Message = union(enum) {
/// Release a slice of CFTypeRefs. Uses alloc to
/// free the slice after releasing all the refs.
release: struct{
/// Release a slice of CFTypeRefs. Uses alloc to free the slice after
/// releasing all the refs.
release: struct {
refs: []*anyopaque,
alloc: Allocator,
},
@@ -142,12 +142,10 @@ fn drainMailbox(self: *Thread) !void {
// log.debug("mailbox message={}", .{message});
switch (message) {
.release => |msg| {
for (msg.refs) |ref| {
macos.foundation.CFRelease(ref);
}
for (msg.refs) |ref| macos.foundation.CFRelease(ref);
// log.debug("Released {} CFTypeRefs.", .{ msg.refs.len });
msg.alloc.free(msg.refs);
}
},
}
}
}

View File

@@ -1,5 +1,6 @@
//! The "os" package contains utilities for interfacing with the operating
//! system.
//! system. These aren't restricted to syscalls or low-level operations, but
//! also OS-specific features and conventions.
pub usingnamespace @import("env.zig");
pub usingnamespace @import("desktop.zig");
@@ -12,6 +13,7 @@ pub usingnamespace @import("mouse.zig");
pub usingnamespace @import("open.zig");
pub usingnamespace @import("pipe.zig");
pub usingnamespace @import("resourcesdir.zig");
pub const CFReleaseThread = @import("cf_release_thread.zig");
pub const TempDir = @import("TempDir.zig");
pub const cgroup = @import("cgroup.zig");
pub const passwd = @import("passwd.zig");

View File

@@ -15,6 +15,7 @@ const xev = @import("xev");
const apprt = @import("../apprt.zig");
const configpkg = @import("../config.zig");
const font = @import("../font/main.zig");
const os = @import("../os/main.zig");
const terminal = @import("../terminal/main.zig");
const renderer = @import("../renderer.zig");
const math = @import("../math.zig");
@@ -25,11 +26,10 @@ const shadertoy = @import("shadertoy.zig");
const assert = std.debug.assert;
const Allocator = std.mem.Allocator;
const ArenaAllocator = std.heap.ArenaAllocator;
const CFReleaseThread = os.CFReleaseThread;
const Terminal = terminal.Terminal;
const Health = renderer.Health;
const CFReleaseThread = @import("../cf_release_thread.zig");
const mtl = @import("metal/api.zig");
const mtl_buffer = @import("metal/buffer.zig");
const mtl_cell = @import("metal/cell.zig");