mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
do not block channel send while draining channel
This commit is contained in:
@ -143,10 +143,7 @@ pub fn run(self: *App) !void {
|
|||||||
|
|
||||||
/// Drain the mailbox.
|
/// Drain the mailbox.
|
||||||
fn drainMailbox(self: *App) !void {
|
fn drainMailbox(self: *App) !void {
|
||||||
var drain = self.mailbox.drain();
|
while (self.mailbox.pop()) |message| {
|
||||||
defer drain.deinit();
|
|
||||||
|
|
||||||
while (drain.next()) |message| {
|
|
||||||
log.debug("mailbox message={s}", .{@tagName(message)});
|
log.debug("mailbox message={s}", .{@tagName(message)});
|
||||||
switch (message) {
|
switch (message) {
|
||||||
.new_window => |msg| _ = try self.newWindow(msg),
|
.new_window => |msg| _ = try self.newWindow(msg),
|
||||||
|
@ -238,14 +238,7 @@ fn drainMailbox(self: *Thread) !void {
|
|||||||
const zone = trace(@src());
|
const zone = trace(@src());
|
||||||
defer zone.end();
|
defer zone.end();
|
||||||
|
|
||||||
// This holds the mailbox lock for the duration of the drain. The
|
while (self.mailbox.pop()) |message| {
|
||||||
// expectation is that all our message handlers will be non-blocking
|
|
||||||
// ENOUGH to not mess up throughput on producers.
|
|
||||||
|
|
||||||
var drain = self.mailbox.drain();
|
|
||||||
defer drain.deinit();
|
|
||||||
|
|
||||||
while (drain.next()) |message| {
|
|
||||||
log.debug("mailbox message={}", .{message});
|
log.debug("mailbox message={}", .{message});
|
||||||
switch (message) {
|
switch (message) {
|
||||||
.focus => |v| {
|
.focus => |v| {
|
||||||
|
@ -162,24 +162,19 @@ fn drainMailbox(self: *Thread) !void {
|
|||||||
// expectation is that all our message handlers will be non-blocking
|
// expectation is that all our message handlers will be non-blocking
|
||||||
// ENOUGH to not mess up throughput on producers.
|
// ENOUGH to not mess up throughput on producers.
|
||||||
var redraw: bool = false;
|
var redraw: bool = false;
|
||||||
{
|
while (self.mailbox.pop()) |message| {
|
||||||
var drain = self.mailbox.drain();
|
// If we have a message we always redraw
|
||||||
defer drain.deinit();
|
redraw = true;
|
||||||
|
|
||||||
while (drain.next()) |message| {
|
log.debug("mailbox message={}", .{message});
|
||||||
// If we have a message we always redraw
|
switch (message) {
|
||||||
redraw = true;
|
.resize => |v| try self.impl.resize(v.grid_size, v.screen_size, v.padding),
|
||||||
|
.write_small => |v| try self.impl.queueWrite(v.data[0..v.len]),
|
||||||
log.debug("mailbox message={}", .{message});
|
.write_stable => |v| try self.impl.queueWrite(v),
|
||||||
switch (message) {
|
.write_alloc => |v| {
|
||||||
.resize => |v| try self.impl.resize(v.grid_size, v.screen_size, v.padding),
|
defer v.alloc.free(v.data);
|
||||||
.write_small => |v| try self.impl.queueWrite(v.data[0..v.len]),
|
try self.impl.queueWrite(v.data);
|
||||||
.write_stable => |v| try self.impl.queueWrite(v),
|
},
|
||||||
.write_alloc => |v| {
|
|
||||||
defer v.alloc.free(v.data);
|
|
||||||
try self.impl.queueWrite(v.data);
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user