diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-18 05:32:59 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-18 05:48:26 -0300 |
| commit | 3f8f66643a1e4840e1cbf0d7a4c5aa8580360ac7 (patch) | |
| tree | acb0c305ed07e229725bfa677d92691a9c4e92fd /src/host_io.zig | |
| parent | 22b5ada4c099618e72af3d33dc274a7c272dd227 (diff) | |
| download | pardes-3f8f66643a1e4840e1cbf0d7a4c5aa8580360ac7.tar.gz pardes-3f8f66643a1e4840e1cbf0d7a4c5aa8580360ac7.zip | |
kinds: a draw (pa_api.draw, ABI 3.2), a kind's job whose answer feeds its pictures alone: job_run over a copy of its input on a worker of the process that shows the pane (the frontend's workers through Kind.drawer, else at once), its answer to job_done with a PA_DRAWN token at the pane's next paint (Kind.deliver), never an event, on the tape, in the digest or sent to another process, each process asking its own from the same call; the header says what a kind promises by it (what job_done keeps of it paint alone reads; never a plain kind's block, nor its token; Debug checks the block is as it was) and addon.zig has draw; a client's pane of a plain kind closed in a speculation leaves its kind's own memory be (its rollback brings the pane back); the window client takes its queue's draws; the addon ABI tests expect 3.2; tui core-test 819/958 (139 skipped), shell-test 993/996, behaviour-test 273/273 (the four addon tests the base failed on its ABI string run again and pass), --replay 20 seeds 0 failures, pane-test 180/181, replicas pass, addon-test 1/1
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'src/host_io.zig')
| -rw-r--r-- | src/host_io.zig | 16 |
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; |
