summaryrefslogtreecommitdiff
path: root/dev/Inbox.zig
diff options
context:
space:
mode:
Diffstat (limited to 'dev/Inbox.zig')
-rw-r--r--dev/Inbox.zig28
1 files changed, 14 insertions, 14 deletions
diff --git a/dev/Inbox.zig b/dev/Inbox.zig
index d8b14221..ed3a9835 100644
--- a/dev/Inbox.zig
+++ b/dev/Inbox.zig
@@ -8,8 +8,8 @@ const Lsp = host_io.Lsp;
const Inbox = @This();
pub const Msg = union(enum) {
- output: struct { pane: u8, gen: u32, bytes: []u8 },
- eof: struct { pane: u8, gen: u32, failure: ?anyerror = null },
+ output: struct { pane: pardes.Pane.Id, gen: u32, bytes: []u8 },
+ eof: struct { pane: pardes.Pane.Id, gen: u32, failure: ?anyerror = null },
lsp: struct { id: u32, rows: ?[]u8 },
lsp_status: []u8,
pipe: selection_pipe.Response,
@@ -96,18 +96,18 @@ pub fn wake(q: *Inbox) void {
if (q.wake_fn) |f| f(q.wake_ctx);
}
-pub fn acceptReader(q: *Inbox, pane: u8, gen: u32) void {
+pub fn acceptReader(q: *Inbox, pane: pardes.Pane.Id, gen: u32) void {
q.lock();
defer q.unlock();
- std.debug.assert(q.readers[pane] == null);
- q.readers[pane] = gen;
+ std.debug.assert(q.readers[pane.index()] == null);
+ q.readers[pane.index()] = gen;
}
-pub fn cancelReader(q: *Inbox, pane: u8, gen: u32) void {
+pub fn cancelReader(q: *Inbox, pane: pardes.Pane.Id, gen: u32) void {
q.lock();
defer q.unlock();
- if (q.readers[pane] != gen) return;
- q.readers[pane] = null;
+ if (q.readers[pane.index()] != gen) return;
+ q.readers[pane.index()] = null;
var i: usize = 0;
while (i < q.len) {
const msg = q.items[(q.head + i) % q.items.len];
@@ -121,14 +121,14 @@ pub fn cancelReader(q: *Inbox, pane: u8, gen: u32) void {
q.space.broadcast(q.io);
}
-pub fn pushOutput(q: *Inbox, pane: u8, gen: u32, bytes: []u8) bool {
+pub fn pushOutput(q: *Inbox, pane: pardes.Pane.Id, gen: u32, bytes: []u8) bool {
q.lock();
- while (!q.closed and q.readers[pane] == gen and q.len >= output_capacity) {
+ while (!q.closed and q.readers[pane.index()] == gen and q.len >= output_capacity) {
q.waiting += 1;
q.space.waitUncancelable(q.io, &q.mutex);
q.waiting -= 1;
}
- if (q.closed or q.readers[pane] != gen) {
+ if (q.closed or q.readers[pane.index()] != gen) {
q.unlock();
q.gpa.free(bytes);
return false;
@@ -186,7 +186,7 @@ pub fn push(q: *Inbox, m: Msg) void {
},
else => {
if (m == .eof) {
- if (q.readers[m.eof.pane] != m.eof.gen) {
+ if (q.readers[m.eof.pane.index()] != m.eof.gen) {
q.unlock();
return;
}
@@ -270,13 +270,13 @@ pub fn deinit(q: *Inbox) void {
/// A pane's reader: its pty's output pushed as it comes, then its end
/// of file; canceled (closePty), it pushes nothing more.
-pub fn startReader(q: *Inbox, pty: std.Io.File, pane: u8, gen: u32) !std.Io.Future(void) {
+pub fn startReader(q: *Inbox, pty: std.Io.File, pane: pardes.Pane.Id, gen: u32) !std.Io.Future(void) {
q.acceptReader(pane, gen);
errdefer q.cancelReader(pane, gen);
return q.io.concurrent(readPty, .{ q, pty, pane, gen });
}
-fn readPty(q: *Inbox, pty: std.Io.File, pane: u8, gen: u32) void {
+fn readPty(q: *Inbox, pty: std.Io.File, pane: pardes.Pane.Id, gen: u32) void {
var buf: [0x10000]u8 = undefined;
var failure: ?anyerror = null;
while (true) {