Files
synapse/synapse/synapse_rust/runtime.pyi
T
Erik Johnston 7ae1d987ef Add a per-homeserver clock to the Rust side (#20294)
This is a prerequisite to being able to add caching on the Rust side.
2026-10-07 11:11:08 +01:00

28 lines
956 B
Python

from synapse.server import HomeServer
class RustRuntime:
"""The per-homeserver state for the Rust side of Synapse.
Holds the tokio thread pool (started lazily on first use, shut down with the
Homeserver). Rust classes that need them take this as a constructor
argument. Get it from `hs.get_rust_runtime()`.
"""
def __init__(
self,
hs: HomeServer,
worker_threads: int = 4,
) -> None: ...
def time_msec(self) -> int:
"""Test utility only. Normal code should use
`hs.get_clock().time_msec()`.
The current time in milliseconds since the Unix epoch, as the Rust side
sees it. This and `Clock.time_msec()` agree because both read the system
clock, `clock_gettime(CLOCK_REALTIME)` on Linux.
"""
def set_virtual_time_msec(millis: int) -> None:
"""Pin the Rust clock to the given time. Only for tests, which run
against a virtual reactor clock."""