From c919b5f81ad6cad55935fa7a22bfda9539dd584f Mon Sep 17 00:00:00 2001 From: eunhhu Date: Tue, 29 Sep 2026 18:12:23 +0100 Subject: Wait for timers on the monotonic clock; events still see the wall clock The terminal, the pixel surfaces and the web page reckoned when a timer was due on the wall clock: set back, a timer waited until the clock came again to the tick it had waited for (Pure's review 004). vega_clock is the monotonic clock; timers are due on it, and a tick sets the time its event sees from the wall clock (vega_now), as before. check.py's clock_set_back runs a timer of 20 ms in the terminal with the wall clock set back an hour 0.2 s in (Pure's build/clock-back.so, an LD_PRELOAD of clock_gettime): 40 ticks in 0.8 s, where Vega before this stops at 9. make check passes it --clock-back. --- surfaces/main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'surfaces/main.c') diff --git a/surfaces/main.c b/surfaces/main.c index 6c7e368..70958e1 100644 --- a/surfaces/main.c +++ b/surfaces/main.c @@ -483,7 +483,7 @@ static int interactive(void) { VegaGrid grid = {0}; drawn = &grid; VegaTimers timers; - vega_timers_start(&timers, app.module, vega_now()); + vega_timers_start(&timers, app.module, vega_clock()); for (;;) { if (resized) { struct winsize size; @@ -494,7 +494,7 @@ static int interactive(void) { } /* Tick what is due, draw, then wait for input, a frame or the next tick. */ bool ticked = false; - long due = vega_timers_run(&timers, &app, vega_now(), &ticked); + long due = vega_timers_run(&timers, &app, vega_clock(), &ticked); char line[VEGA_TEXT + 4]; vega_draw(&grid, &app, &screen, line, shown_entry(line), typing); paint_terminal(&grid); @@ -505,7 +505,7 @@ static int interactive(void) { app.now = vega_now(); if (ready == 0) { if (screen.ticks) pure_app_frame(&app); - if (module_changed()) vega_timers_start(&timers, app.module, app.now); + if (module_changed()) vega_timers_start(&timers, app.module, vega_clock()); continue; } if (ready < 0) continue; /* a signal, such as a resize */ @@ -647,7 +647,7 @@ static int live(VegaInput *input, unsigned columns, unsigned rows, bool recorded signal(SIGTERM, on_stop); } VegaTimers timers; - vega_timers_start(&timers, app.module, vega_now()); + vega_timers_start(&timers, app.module, vega_clock()); char path[512] = ""; unsigned long differing = 0; bool open_input = true, printed = false; @@ -664,7 +664,7 @@ static int live(VegaInput *input, unsigned columns, unsigned rows, bool recorded bool dirty = true; while (!stopping && !(node && node->stopping(node->host))) { bool ticked = false; - long due = node ? -1 : vega_timers_run(&timers, &app, vega_now(), &ticked); + long due = node ? -1 : vega_timers_run(&timers, &app, vega_clock(), &ticked); PureSnapshot *snapshot = node ? node->read(node->host, &app) : NULL; dirty = dirty || ticked || snapshot || access_acted; access_acted = false; -- cgit v1.2.3