summaryrefslogtreecommitdiff
path: root/src/tui/tui.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/tui/tui.zig')
-rw-r--r--src/tui/tui.zig21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/tui/tui.zig b/src/tui/tui.zig
index 68b97ba2..414fe776 100644
--- a/src/tui/tui.zig
+++ b/src/tui/tui.zig
@@ -150,6 +150,8 @@ const Msg = union(enum) {
pipe_done: selection_pipe.Response,
/// A streaming search's rows (pardes.Stream).
search_rows: pardes.Stream.Batch,
+ /// A kind's job done on a worker (host_io.KindJob).
+ kind_job: *host_io.KindJob,
files_changed,
fs_ready,
/// A replica's connection, handed over by the daemon (Peers).
@@ -1592,6 +1594,7 @@ fn localSession(
host_io.startWorkers(io, allocs);
defer host_io.stopWorkers();
+ options.addons = pardes.Addon.scan();
var core = if (upgrade.resumed) |*rec|
try upgrade.load(gpa, allocs.pardes, options, rec)
@@ -1654,6 +1657,7 @@ fn localSession(
sh.lsp_task = null;
}
sh.pipe_tasks.cancelAll(io);
+ sh.job_tasks.cancelAll(io);
// Its worker may be waiting on the loop's queue for room.
core.stream.cancelTask();
file_watch.stop(sh.inotify_fd);
@@ -1678,6 +1682,7 @@ fn localSession(
response.deinit(gpa);
},
.search_rows => |b| b.deinit(gpa),
+ .kind_job => |j| j.drop(),
.attach => |a| {
_ = libc.close(a.tty);
if (a.stub >= 0) _ = libc.close(a.stub);
@@ -1849,6 +1854,7 @@ const Shell = struct {
watch_task: ?std.Io.Future(anyerror!void) = null,
lsp_task: ?host_io.Lsp.Task = null,
pipe_tasks: PipeTasks = .{},
+ job_tasks: PipeTasks = .{},
threads_ok: bool = false,
check_files: bool = false,
// ponytail: one bracketed paste at a time for every terminal: keys
@@ -1957,6 +1963,7 @@ const Shell = struct {
.lsp = lsp,
.pipe = pipe,
.search = search,
+ .job = job,
};
fn clockNow(ctx: ?*anyopaque) u64 {
@@ -2552,6 +2559,10 @@ const Shell = struct {
core.update(.{ .search = b });
b.deinit(s.gpa);
},
+ .kind_job => |j| {
+ s.job_tasks.finish(s.io, j.id);
+ j.land(core);
+ },
}
return false;
}
@@ -2924,6 +2935,16 @@ const Shell = struct {
pardes.Stream.runHere(s.core, gen);
}
+ fn job(ctx: ?*anyopaque, pane: u8, serial: u32, token: u32) void {
+ const s = of(ctx);
+ if (!s.threads_ok) return host_io.KindJob.runHere(s.core, pane, serial, token);
+ host_io.KindJob.start(s.io, s.core, &s.job_tasks, pane, serial, token, s, struct {
+ fn deliver(c: ?*anyopaque, j: *host_io.KindJob) void {
+ of(c).loop.postEvent(.{ .kind_job = j }) catch j.drop();
+ }
+ }.deliver);
+ }
+
/// The loop's queue waits for room (a wait the worker's cancel ends).
fn deliverSearch(ctx: ?*anyopaque, batch: pardes.Stream.Batch) bool {
const s = of(ctx);