diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Messages.zig | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/Messages.zig b/src/Messages.zig index 4cf81ac5..e1d18849 100644 --- a/src/Messages.zig +++ b/src/Messages.zig @@ -197,7 +197,9 @@ fn showMessage(p: *Pardes, id: usize, text: []const u8, stack: bool) void { const arrives = pane.msg_len == 0 or pane.msg_life.phase == .leaving; for (text[0..n], pane.msg[0..n]) |c, *cell| cell.* = if (c < 0x20 or c == 0x7f) ' ' else c; pane.msg_len = @intCast(n); - pane.msg_said_ms = @intCast(p.now_ns / std.time.ns_per_ms); + // The clock when it was said (the session clock is the last pump's, + // and a 9P write after an idle hour would say it an hour ago). + pane.msg_said_ms = pardes.tape.value(.clock, nowMs, .{}); p.needs_frame = true; if (arrives) { pane.msg_life = .{ .phase = if (p.settings.message_animation and n > 0) .entering else .shown }; @@ -219,11 +221,17 @@ fn showMessage(p: *Pardes, id: usize, text: []const u8, stack: bool) void { /// while a step is out and must change nothing. /// ponytail: a pane's older lines go with its newest, not each on its own /// clock; the render pipeline's clock will give every line its own. +fn nowMs() i64 { + if (comptime !pardes.hosted) return 0; + var ts: std.c.timespec = undefined; + if (std.c.clock_gettime(.MONOTONIC, &ts) != 0) return 0; + return @as(i64, ts.sec) * 1000 + @divTrunc(@as(i64, ts.nsec), 1_000_000); +} + pub fn expireUnattended(p: *Pardes) void { if (!p.unattended) return; - // The session's clock (`advance`), as every tick's: no replica reads - // its own. - const now: i64 = @intCast(p.now_ns / std.time.ns_per_ms); + // The clock as the session that recorded read it (src/tape.zig). + const now = pardes.tape.value(.clock, nowMs, .{}); for (p.panes) |slot| { const pane = slot orelse continue; if (pane.msg_len == 0 and pane.msg_older_len == 0) continue; |
