aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/src/termio/mailbox.zig
diff options
context:
space:
mode:
authorCan Celik <ogulcancelik@gmail.com>2026-09-10 21:51:57 +0300
committerGitHub <noreply@github.com>2026-09-10 21:51:57 +0300
commit425c86179791cd32e2d4ce0ae7f269940b4b0663 (patch)
treee52c4383a6d69216cbe2a32638bf90841d7e2189 /vendor/libghostty-vt/src/termio/mailbox.zig
parent90e947a6e26e02f10ec7f1694c4eb5b78a86406b (diff)
chore: upgrade libghostty and preserve terminal behavior (#3906)
Diffstat (limited to 'vendor/libghostty-vt/src/termio/mailbox.zig')
-rw-r--r--vendor/libghostty-vt/src/termio/mailbox.zig15
1 files changed, 9 insertions, 6 deletions
diff --git a/vendor/libghostty-vt/src/termio/mailbox.zig b/vendor/libghostty-vt/src/termio/mailbox.zig
index 2725d024..a053aaab 100644
--- a/vendor/libghostty-vt/src/termio/mailbox.zig
+++ b/vendor/libghostty-vt/src/termio/mailbox.zig
@@ -1,6 +1,7 @@
const std = @import("std");
const Allocator = std.mem.Allocator;
-const xev = @import("../global.zig").xev;
+const global = @import("../global.zig");
+const xev = global.xev;
const renderer = @import("../renderer.zig");
const termio = @import("../termio.zig");
const BlockingQueue = @import("../datastruct/main.zig").BlockingQueue;
@@ -46,6 +47,7 @@ pub const Mailbox = union(enum) {
pub fn deinit(self: *Mailbox, alloc: Allocator) void {
switch (self.*) {
.spsc => |*v| {
+ while (v.queue.pop(global.io())) |msg| msg.deinit();
v.queue.destroy(alloc);
v.wakeup.deinit();
},
@@ -61,13 +63,13 @@ pub const Mailbox = union(enum) {
pub fn send(
self: *Mailbox,
msg: termio.Message,
- mutex: ?*std.Thread.Mutex,
+ mutex: ?*std.Io.Mutex,
) void {
switch (self.*) {
.spsc => |*mb| send: {
// Try to write to the queue with an instant timeout. This is the
// fast path because we can queue without a lock.
- if (mb.queue.push(msg, .{ .instant = {} }) > 0) break :send;
+ if (mb.queue.push(global.io(), msg, .{ .instant = {} }) > 0) break :send;
// If we enter this conditional, the queue is full. We wake up
// the writer thread so that it can process messages to clear up
@@ -75,6 +77,7 @@ pub const Mailbox = union(enum) {
// lock so we need to unlock.
mb.wakeup.notify() catch |err| {
log.warn("failed to wake up writer, data will be dropped err={}", .{err});
+ msg.deinit();
return;
};
@@ -87,9 +90,9 @@ pub const Mailbox = union(enum) {
// are other messages in the writer queue (resize, focus) that
// could acquire the lock. This is why we have to release our lock
// here.
- if (mutex) |m| m.unlock();
- defer if (mutex) |m| m.lock();
- _ = mb.queue.push(msg, .{ .forever = {} });
+ if (mutex) |m| m.unlock(global.io());
+ defer if (mutex) |m| m.lockUncancelable(global.io());
+ if (mb.queue.push(global.io(), msg, .{ .forever = {} }) == 0) msg.deinit();
},
}
}