diff options
Diffstat (limited to 'src/pardes.zig')
| -rw-r--r-- | src/pardes.zig | 66 |
1 files changed, 42 insertions, 24 deletions
diff --git a/src/pardes.zig b/src/pardes.zig index 02983c84..cc55d695 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -4710,6 +4710,9 @@ pub const Pardes = struct { view: u8 = 0, views_open: u8 = 1, parked: [views.max]?*views.Parked = @splat(null), + /// The views no frontend here draws: a replica client's, which its own + /// process draws (src/replica.zig). A pump skips them. + undrawn: u8 = 0, /// per-update scratch (paneCursorLines, selection text); reset each update scratch: std.heap.ArenaAllocator, /// The arena each frame's Surface text is built in, reset by `pump`. Hosts @@ -4739,7 +4742,7 @@ pub const Pardes = struct { "effects", "effects_head", "effects_len", "in_q", "in_head", "in_len", // The views not live: written whenever one goes out, so the // live one's slot is stale (views.zig). - "parked", + "parked", "undrawn", // How this process was started, and the last dump it made for // its host to write: a session loaded elsewhere has its own. "opts", "dump_out", @@ -6056,13 +6059,6 @@ pub const Pardes = struct { } } - /// What a step leaves queued, its inputs and its effects, taken now: - /// the session at a step boundary (an Upgrade's dump, upgrade.zig). - pub fn settle(p: *Pardes) void { - while (p.nextQueued()) |ev| p.update(ev); - while (p.nextEffect()) |e| p.perform(e); - } - pub fn pump(p: *Pardes, host: Host) !void { p.host = host; const taped = tape.enter(p, .pump); @@ -6087,15 +6083,7 @@ pub const Pardes = struct { } p.frames.mark_start = FrameStats.nowNs(); if (v.now) |clock| p.advance(clock(h.ctx)); - // What a 9P open wrote in a row goes in once the writes pause. - ctlfs.pane.flushPausedBatch(p); - // ...and what a /pager open was written before its close. - ctlfs.ctl.fillClosedPagers(p); - // ...and the last line of an open closed with no newline after it. - ctlfs.runClosedLines(p); - while (p.nextQueued()) |ev| p.update(ev); - while (p.nextEffect()) |e| p.perform(e); - turn.bump(&turn.epoch); + p.settle(); // A quitting frame has already freed what it would draw. if (p.quit) return; if (v.poll_frame) |f| f(h.ctx); @@ -6111,13 +6099,17 @@ pub const Pardes = struct { if (v.watched) |f| if (!f(h.ctx)) return; // The other views first, each into its own window or terminal. if (views.several(p)) try views.drawOthers(p, h); - _ = p.frame_arena.reset(.{ .retain_with_limit = memory.limits.frame_kept }); - p.frames.mark_update = FrameStats.nowNs(); - p.frames.view = if (p.panes[p.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| f(h.ctx, surface); - Stream.askAhead(p); + // A replica client's view live (its input the last): its own + // process draws it. + if (p.undrawn & (@as(u8, 1) << @intCast(p.view)) == 0) { + _ = p.frame_arena.reset(.{ .retain_with_limit = memory.limits.frame_kept }); + p.frames.mark_update = FrameStats.nowNs(); + p.frames.view = if (p.panes[p.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| f(h.ctx, surface); + Stream.askAhead(p); + } // Settled before post_present: a shell ticks there, and what that // tick moves owes the next frame. const skipped = p.present_skipped; @@ -6129,6 +6121,32 @@ pub const Pardes = struct { p.frames.record(FrameStats.nowNs(), owed or p.continuous(), skipped); } + /// 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). + pub fn settle(p: *Pardes) void { + // What a 9P open wrote in a row goes in once the writes pause. + ctlfs.pane.flushPausedBatch(p); + // ...and what a /pager open was written before its close. + ctlfs.ctl.fillClosedPagers(p); + // ...and the last line of an open closed with no newline after it. + ctlfs.runClosedLines(p); + while (p.nextQueued()) |ev| p.update(ev); + while (p.nextEffect()) |e| p.perform(e); + turn.bump(&turn.epoch); + } + + /// A replica client's input settled on the authority (src/replica.zig): + /// a pump that waits on nothing, reads no clock and draws nothing, so + /// the client's own core can apply the same at once and expect the + /// authority's tape of it to read the same. The session's own pump + /// draws it after. + pub fn step(p: *Pardes) void { + const taped = tape.enter(p, .step); + defer tape.leave(p, taped); + p.settle(); + } + /// One request of the control filesystem, from whichever thread has the /// turn (`pardes.turn`). Not an event: it neither sweeps nor resets /// anything the editor's own step may be in the middle of using, so it |
