diff options
Diffstat (limited to 'src/Kind.zig')
| -rw-r--r-- | src/Kind.zig | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/Kind.zig b/src/Kind.zig index 374a2d81..a3d20f30 100644 --- a/src/Kind.zig +++ b/src/Kind.zig @@ -138,7 +138,7 @@ pub const Slot = struct { // jobs' inputs, its file's hash, a placeholder's record), and what // a frame makes (the thumb, the pointer, whether one was drawn: a // view's, never a step's). - .local = .{ "ops", "st", "gpa", "arena", "plain", "file", "opened", "reloads", "jobs", "tokens", "record", "thumb_at", "thumb_span", "pointer", "painted", "over", "shadow", "used" }, + .local = .{ "ops", "st", "gpa", "arena", "plain", "file", "opened", "reloads", "jobs", "record", "thumb_at", "thumb_span", "pointer", "painted", "over", "shadow", "used" }, }; /// Its kind's code here; null in a placeholder (`live` false: its kind /// not in the registry, its record kept for the day it comes) or a @@ -175,7 +175,9 @@ pub const Slot = struct { next_tick: u64 = 0, /// PA_FOCUSED as `tick` was last told. focused: bool = false, - /// Its jobs' inputs, until the host takes them (Effect.job). + /// Its jobs' inputs, until the host takes them (Effect.job); and the + /// last token it gave one, which every core gives alike (dumped: a + /// client joined later numbers its next job as the session does). jobs: [4]?Job = @splat(null), tokens: u32 = 0, /// A placeholder's: the kind's record, kept whole. @@ -979,6 +981,11 @@ const Call = struct { tape.diverged(why.print("addon {s}: its state after {s} is not the session's (it breaks PA_PLAIN): the session's alone now", .{ cl.slot.nameOf(), cl.name })); } cl.slot.state = o.state; + // Its last job's token the session's, on a core whose kind asked + // none here (a Shadow's). + for (o.jobs) |token| if (token != 0) { + cl.slot.tokens = token; + }; if (cl.p) |p| if (p.panes[cl.id]) |pane| for (o.jobs) |token| if (token != 0) p.emit(.{ .job = .{ .pane = @intCast(cl.id), .serial = pane.serial, .token = token } }); for (o.cancels) |token| if (token != 0) { for (&cl.slot.jobs) |*j| if (j.*) |job| if (job.token == token) { @@ -1101,14 +1108,16 @@ pub const api: c.pa_api = .{ cl.began += @import("FrameStats.zig").nowNs() -| t0; }; const s = cl.slot; - const free = for (&s.jobs) |*j| { + const asked = std.mem.indexOfScalar(u32, &cl.jobs, 0) orelse return 0; + // A client's (a plain kind's code here) runs none: its token + // alone, as the session's; the answer comes on the tape. + const free = if (tape.replaying()) null else for (&s.jobs) |*j| { if (j.* == null) break j; } else return 0; - const asked = std.mem.indexOfScalar(u32, &cl.jobs, 0) orelse return 0; - const copy = s.gpa.dupe(u8, if (in) |b| @as([*]const u8, @ptrCast(b))[0..n] else "") catch return 0; + const copy = if (free != null) s.gpa.dupe(u8, if (in) |b| @as([*]const u8, @ptrCast(b))[0..n] else "") catch return 0 else ""; s.tokens +%= 1; if (s.tokens == 0) s.tokens = 1; - free.* = .{ .token = s.tokens, .in = copy }; + if (free) |slot| slot.* = .{ .token = s.tokens, .in = @constCast(copy) }; // Emitted as the call ends (Call.end), on every core. cl.jobs[asked] = s.tokens; return s.tokens; |
