mirror of
https://github.com/element-hq/synapse.git
synced 2026-11-04 15:37:49 +00:00
Tokio's timers run on real time, but trial drives a virtual reactor clock that only moves when a test advances it. A Rust task that sleeps with `tokio::time::sleep` under trial waits out real time while the test believes none has passed. `Clock::sleep` sleeps on the virtual clock while a test has pinned it: `set_virtual_time_msec` wakes the sleepers that are due. Otherwise it is `tokio::time::sleep`. Code that sleeps takes a `Sleeper`, so that its Rust unit tests can use tokio's pausable clock instead, since the virtual time is process-global and an earlier test may have pinned it. The federation sender port needs this for its backoff and well-known retry sleeps. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R5b7Ruy4cgt27Mjq6Ptxbb