diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-20 04:16:41 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-20 04:16:41 -0300 |
| commit | 5b7124d10f9b2db8d1c5e99eacb9b6d2fffff0cc (patch) | |
| tree | dc50936490ad8636f5431da30ec3aaa38339c936 /core/Core.zig | |
| parent | 6e8735895d04c0073eb28cc1a2f431a2ba587e9d (diff) | |
| parent | 8fb080c6208bccf9ef12eca630b0534312ae5fe7 (diff) | |
| download | pardes-5b7124d10f9b2db8d1c5e99eacb9b6d2fffff0cc.tar.gz pardes-5b7124d10f9b2db8d1c5e99eacb9b6d2fffff0cc.zip | |
integration: the core's calls out to the host go through the tape's handle, on the devices once and the attach that is always a client: pardes-handle-6 (6a, 6b, 6c, 8a: p.tape.host(p, .name, .{ args }) derived from the Host table; Wrap, hostOf and wrap deleted; no line of core/ outside the tape names the host's table, held by root.zig's scan; the tape's bytes unmoved) and pardes-merge30, merged without a textual conflict; tui core-test 857/1008 (151 skipped), shell-test 1048/1051, the window builds; the coordinator's gate in the ledger (reorg/merge31)
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/Core.zig')
| -rw-r--r-- | core/Core.zig | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/core/Core.zig b/core/Core.zig index 9a542940..e2f8cd8a 100644 --- a/core/Core.zig +++ b/core/Core.zig @@ -1324,18 +1324,15 @@ fn nextQueued(p: *Pardes) ?Event { } pub fn hostForegroundName(p: *const Pardes, id: usize, buf: []u8) ?[]const u8 { - const f = p.host.vtable.fg_name orelse return null; - return f(p.host.ctx, .at(id), buf); + return p.tape.host(p, .fg_name, .{ .at(id), buf }) orelse null; } pub fn hostTtyTaken(p: *const Pardes, id: usize) bool { - const f = p.host.vtable.tty_taken orelse return false; - return f(p.host.ctx, .at(id)); + return p.tape.host(p, .tty_taken, .{.at(id)}) orelse false; } pub fn hostKillJob(p: *const Pardes, id: usize) bool { - const f = p.host.vtable.kill_job orelse return false; - return f(p.host.ctx, .at(id)); + return p.tape.host(p, .kill_job, .{.at(id)}) orelse false; } /// A terminal whose shell could not be started: said, and a run waiting @@ -1471,25 +1468,22 @@ pub fn animationActive(p: *const Pardes) bool { } pub fn pump(p: *Pardes, host: Host) !void { - // By hand, not `taped`: the host is set before the enter, which wraps it, and is no input. + // By hand, not `taped`: the host is set before the enter, which says which functions it has if it is another, and is no input. p.host = host; const taped = pardes.tape.enter(p, .pump); defer pardes.tape.leave(p, taped); - // The host as the tape sees it, while it records. - const h = p.host; - const v = h.vtable; - if (v.wait_input) |f| { + if (p.tape.has(p, .wait_input)) { // Asleep until input or until the core's next deadline // (nextWake); 0 is no timeout at all. // The clock read whether or not it is wanted: what a replica // waits on is its own (a picture decoding wakes only a frame // that draws it), and the tape has the same calls either way. - const now = if (v.now) |clock| clock(h.ctx) else p.clock.now_ns; + const now = p.tape.host(p, .now, .{}) orelse p.clock.now_ns; const timeout: u32 = if (p.nextWake()) |due| wake: { const ms = ((due -| now) + std.time.ns_per_ms - 1) / std.time.ns_per_ms; break :wake @intCast(std.math.clamp(ms, 1, std.math.maxInt(u32))); } else 0; - f(h.ctx, timeout); + _ = p.tape.host(p, .wait_input, .{timeout}); } // Detached, nobody's key dismisses a message: they go on the clock, // here in the step, where the clock read is taped (the host's wait @@ -1497,46 +1491,54 @@ pub fn pump(p: *Pardes, host: Host) !void { // go). Messages.expireUnattended(p); p.frames.mark_start = FrameStats.nowNs(); - if (v.now) |clock| p.advance(clock(h.ctx)); + if (p.tape.host(p, .now, .{})) |now| p.advance(now); p.settle(); // A quitting frame has already freed what it would draw. if (p.quit) return; - if (v.poll_frame) |f| f(h.ctx); + _ = p.tape.host(p, .poll_frame, .{}); // Nothing to draw: do not spend a frame, and above all do not block on // the display for one. This is what keeps the frame rate governing // rendering and nothing else. // A shell with a clock draws what `advance` stepped; one without // steps its own `.tick`s and draws while a deadline is due. - if (!p.needs_frame and (v.now != null or !p.animationActive())) return p.frames.idle(); + if (!p.needs_frame and (p.tape.has(p, .now) or !p.animationActive())) return p.frames.idle(); // No one to see it: the frame stays owed (needs_frame), not drawn. // A pty streaming into an unwatched session spent most of its time // drawing what nobody looked at. - if (v.watched) |f| if (!f(h.ctx)) return; + if (!(p.tape.host(p, .watched, .{}) orelse true)) return; // The one view this process shows (a replica client's is its own // process's to draw), drawn as it is if another's is live. // Not shown by the frontend (Host.present): owed. var skipped = false; const shown = Views.shown(p); if (shown != p.live) { - if (shown) |k| skipped = !try Views.drawOne(p, k, .{ .ctx = h.ctx, .f = v.present }); + if (shown) |k| skipped = !try Views.drawOne(p, k, .{ .ctx = p, .f = presentTaped }); } else { _ = p.frame_arena.reset(.{ .retain_with_limit = memory.limits.frame_kept }); p.frames.mark_update = FrameStats.nowNs(); p.frames.view = if (p.panes[p.view().active]) |pane| pane.scroll() else 0; const surface = try p.render(p.frame_arena.allocator()); p.frames.mark_render = FrameStats.nowNs(); - if (v.present) |f| skipped = !f(h.ctx, surface); + skipped = !(p.tape.host(p, .present, .{surface}) orelse true); Stream.askAhead(p); } // Settled before post_present: a shell ticks there, and what that // tick moves owes the next frame. p.needs_frame = skipped; - if (v.post_present) |f| f(h.ctx); + _ = p.tape.host(p, .post_present, .{}); // Still moving: the next frame is owed a period from now. const owed = if (p.nextWake()) |due| due <= p.clock.stepped_ns + frame_ns else false; p.frames.record(FrameStats.nowNs(), owed, skipped); } +/// The pump's other view presented as its own is, through the tape: +/// `present` stays inside `views.within`, whose live view the host's +/// `presented` reads. +fn presentTaped(ctx: ?*anyopaque, surface: *const pardes.Surface) bool { + const p: *Pardes = @ptrCast(@alignCast(ctx.?)); + return p.tape.host(p, .present, .{surface}) orelse true; +} + /// What a pump does between its wait and its frame: the queued inputs /// and the effects. Also the session at a step boundary, taken now (an /// Upgrade's dump, upgrade.zig). |
