summaryrefslogtreecommitdiff
path: root/runtime/client.zig
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/client.zig')
-rw-r--r--runtime/client.zig20
1 files changed, 18 insertions, 2 deletions
diff --git a/runtime/client.zig b/runtime/client.zig
index 28ed6a52..7ba9e790 100644
--- a/runtime/client.zig
+++ b/runtime/client.zig
@@ -142,8 +142,7 @@ pub fn Loop(comptime Frontend: type) type {
var done: std.atomic.Value(bool) = .init(false);
const reader = try std.Thread.spawn(.{}, read, .{ l, s, &done });
while (!link.quit) {
- const ms = l.before() orelse break;
- l.fe.wait(l, ms);
+ if (!l.pass()) break;
l.after();
}
if (s.env.get("PARDES_REPLICA_STATS")) |file| link.writeStats(file);
@@ -182,6 +181,23 @@ pub fn Loop(comptime Frontend: type) type {
l.fe.ended();
}
+ /// A pass up to its wait, and the wait: false when the frontend
+ /// ended the loop.
+ pub fn pass(l: *L) bool {
+ const ms = l.before() orelse return false;
+ l.fe.wait(l, ms);
+ return true;
+ }
+
+ /// The loop of a frontend that is woken from outside (the soak's,
+ /// test/replicas.zig, whose clock and link are a simulation's):
+ /// what woke it taken already (`input`, `take`), the rest of the
+ /// pass and the next up to its wait, as `run` goes round.
+ pub fn woken(l: *L) void {
+ l.after();
+ if (!l.link.quit) _ = l.pass();
+ }
+
/// A pass up to its wait: the frontend's own work, its predicted
/// echo judged and caught up (once a frame), its view drawn if
/// anything changed (else its own motion moved on), and how long