Skip to main content

probabilistic_rs/
runtime.rs

1use std::sync::OnceLock;
2use tokio::runtime::Runtime;
3
4static RUNTIME: OnceLock<Runtime> = OnceLock::new();
5
6/// Returns a reference to the shared Tokio runtime.
7///
8/// All background snapshot tasks and blocking async calls share this single runtime,
9/// ensuring that multiple filter instances do not each spin up their own executor.
10pub fn get_runtime() -> &'static Runtime {
11    RUNTIME.get_or_init(|| {
12        Runtime::new().expect("Failed to create shared Tokio runtime")
13    })
14}