summaryrefslogtreecommitdiff
path: root/src/host_io.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-18 08:29:46 -0300
committerGabriel Schneider <[email protected]>2026-11-18 08:29:46 -0300
commit5c5e0102f92938f433a3465c92818be810c1ef78 (patch)
tree379cf5e47f2e281934236482d7a5f78db732b18b /src/host_io.zig
parent8640d280ebc48b0d2658aa13bee2f9ad933c39f3 (diff)
parent3350156db428656fa8e583d1971663e1c4a215b0 (diff)
downloadpardes-5c5e0102f92938f433a3465c92818be810c1ef78.tar.gz
pardes-5c5e0102f92938f433a3465c92818be810c1ef78.zip
integration: the client path's round 1 (the tty client drawing as the own terminal does, a detached session's deltas a unit a frame, the window client's wait, pardes-gui --detach as pardes) with addons in a client part 2 (a draw, ABI 3.2; the image kind where it is shown): no conflict; tui core-test 819/958 (139 skipped), shell-test 993/996, behaviour-test 273/273, replicas pass, pane-test 180/181; the window's suites and its frame corpus NOT run on this merge yet (disk)
Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'src/host_io.zig')
-rw-r--r--src/host_io.zig16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/host_io.zig b/src/host_io.zig
index b086b5fe..d199c839 100644
--- a/src/host_io.zig
+++ b/src/host_io.zig
@@ -80,6 +80,8 @@ pub const Host = struct {
/// A kind's job (Effect.job), taken off its pane: its input, its kind's
/// `job_run` and generation; run on a worker (or here), its answer the
/// core's `job` event. Its library is held until it lands (Addon.holdJob).
+/// A draw (api.draw, `draw`) is one of this process's alone: never an
+/// event, its answer kept for the pane's next paint (Kind.landDraw).
pub const KindJob = struct {
gpa: std.mem.Allocator,
pane: u8,
@@ -92,6 +94,8 @@ pub const KindJob = struct {
arena: std.heap.ArenaAllocator,
out: []u8 = &.{},
id: u32 = 0,
+ /// A draw's: the core it was asked in.
+ draw: ?*const pardes.Pardes = null,
pub fn take(p: *pardes.Pardes, pane: u8, serial: u32, token: u32) ?*KindJob {
const pn = p.panes[pane] orelse return null;
@@ -123,6 +127,7 @@ pub const KindJob = struct {
/// Its answer to the core, and it gone.
pub fn land(j: *KindJob, p: *pardes.Pardes) void {
+ if (j.draw != null) return pardes.Kind.landDraw(p, j);
p.update(.{ .job = .{ .pane = j.pane, .serial = j.serial, .token = j.token, .gen = j.gen, .bytes = j.out } });
j.drop();
}
@@ -137,6 +142,12 @@ pub const KindJob = struct {
/// On a worker of `io`, posting itself to `sink` done: a host's `job`.
pub fn start(io: std.Io, p: *pardes.Pardes, tasks: *selection_pipe.Tasks, pane: u8, serial: u32, token: u32, ctx: ?*anyopaque, sink: *const fn (?*anyopaque, *KindJob) void) void {
const j = take(p, pane, serial, token) orelse return;
+ if (!go(io, tasks, j, ctx, sink)) here(j, p);
+ }
+
+ /// `j` on a worker of `io`, posting itself to `sink` done; false when
+ /// none could take it.
+ pub fn go(io: std.Io, tasks: *selection_pipe.Tasks, j: *KindJob, ctx: ?*anyopaque, sink: *const fn (?*anyopaque, *KindJob) void) bool {
next_id +%= 1;
j.id = next_id | 0x8000_0000;
const work = struct {
@@ -145,9 +156,10 @@ pub const KindJob = struct {
s(c, job);
}
}.work;
- if (tasks.full()) return here(j, p);
- const future = io.concurrent(work, .{ j, ctx, sink }) catch return here(j, p);
+ if (tasks.full()) return false;
+ const future = io.concurrent(work, .{ j, ctx, sink }) catch return false;
_ = tasks.add(.{ .id = j.id, .future = future });
+ return true;
}
var next_id: u32 = 0;