Skip to main content

Crate reifydb_runtime

Crate reifydb_runtime 

Source
Expand description

Process-level runtime: actor system, thread pools, async executors, time and randomness, and the synchronisation primitives the rest of the workspace builds on. The SharedRuntime handle carries the actor system, the pool set, the clock, and the seeded RNG together so any subsystem that needs to spawn work, sleep, or generate ids gets a consistent view of the world.

The crate abstracts platform differences: native targets get a tokio-backed pool, WebAssembly gets a single-task executor, the deterministic-simulation target (reifydb_target = "dst") gets a virtual scheduler. All three sit behind the same SharedRuntime API so callers do not branch on platform.

Invariant: SharedRuntime::seeded(...) is what produces a deterministic ReifyDB - same seed, same trace. Any source of non-determinism inside the runtime (an unmocked clock, an unseeded RNG, a pool that schedules outside the seeded executor) defeats DST replays and breaks the simulation harness.

Modules§

actor
Lightweight actor system. Each actor owns its mailbox, processes messages serially, and replies through a typed channel; the system handle spawns actors onto the runtime’s pools and supervises their lifecycle. Timers, testing fixtures, and reply patterns sit alongside so subsystem code can build on a consistent message-passing base without rolling its own concurrency primitives.
context
Sources of non-determinism the workspace consumes: the wall clock and the random number generator. Both have mockable variants so a deterministic-simulation run replaces them with seeded equivalents and reproduces the same trace bit-for-bit. Anything in the workspace that needs the time of day or a random value reaches for these handles instead of pulling from std.
hash
pool
Thread-pool abstraction. Splits work across three named pools - async I/O, system, and query - so the runtime can size each independently. Native targets get the tokio-backed implementation; single-threaded and DST targets get the in-memory variant. The Pools type both impls hand back is what SharedRuntime carries around.
sync
Synchronisation primitives that are mockable under deterministic simulation. The mutex, rwlock, condvar, waiter, and concurrent map exposed here delegate to native equivalents on real targets and to a virtualised scheduler on DST. Code that builds on std::sync directly cannot be replayed; code that builds on this module can.

Structs§

SharedRuntime
SharedRuntimeConfig