diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/replicas.zig | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/test/replicas.zig b/test/replicas.zig index fa7c84e8..8ae46a31 100644 --- a/test/replicas.zig +++ b/test/replicas.zig @@ -111,8 +111,22 @@ const Host = struct { h.detach_view = h.core.?.live; } - const vtable: pardes.Host.VTable = .{ .watched = watched, .pty_write = ptyWrite, .set_clipboard = ignore }; - const clocked_vtable: pardes.Host.VTable = .{ .watched = watched, .pty_write = ptyWrite, .set_clipboard = ignore, .now = now, .detach = detach }; + /// A kind's job on a worker, as tui.zig's `job` runs one: its answer + /// the session's own step `draw_us` later (`.draw`, `Authority.output`), + /// as a worker's is its loop's event (with no `job`, Effect.perform runs + /// it at once on the core's side, inside the perform that asked it, + /// where no tape records it: a client replays that perform without it). + /// At the setup, before any client, at once inside this call. + fn job(ctx: ?*anyopaque, pane: u8, serial: u32, token: u32) void { + const h: *Host = @ptrCast(@alignCast(ctx.?)); + const j = pardes.host_io.KindJob.take(h.core.?, pane, serial, token) orelse return; + if (Draws.go(null, j)) return; + j.run(); + j.land(h.core.?); + } + + const vtable: pardes.Host.VTable = .{ .watched = watched, .pty_write = ptyWrite, .set_clipboard = ignore, .job = job }; + const clocked_vtable: pardes.Host.VTable = .{ .watched = watched, .pty_write = ptyWrite, .set_clipboard = ignore, .now = now, .detach = detach, .job = job }; fn host(h: *Host) pardes.Host { return .{ .ctx = h, .vtable = if (h.clocked) &clocked_vtable else &vtable }; @@ -1070,6 +1084,14 @@ fn run(r: Run, dir: []const u8, totals: *Totals) !void { // a frame owed; one of a core gone since is let go. const j = Draws.jobs.orderedRemove(0); j.run(); + // A state job's answer: a step of the session's own. + if (j.draw == null) { + session.enter(); + host.now_ns = std.time.ns_per_s + m.at * 1000; + a.output(.{ .job = .{ .pane = j.pane, .serial = j.serial, .token = j.token, .gen = j.gen, .bytes = j.out } }); + j.drop(); + continue; + } if (j.draw == @as(?*const pardes.Pardes, a.core)) { session.enter(); pardes.Kind.landDraw(a.core, j); |
