cube-tui 0.1.9

Terminal UI timer and session manager for speedcubing, with optional web dashboard and BLE (GAN) timer support.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use std::sync::OnceLock;
use tokio::runtime::Runtime;

static RUNTIME: OnceLock<Runtime> = OnceLock::new();

/// Returns the shared tokio runtime used by the bluetooth scanner, the web
/// dashboard, and any other async subsystem.
///
/// On first call a multi-threaded runtime is lazily created. Callers must
/// ensure the runtime is dropped (process exit) before the terminal is
/// restored, otherwise background tasks may still write to the tty.
pub fn runtime() -> &'static Runtime {
    RUNTIME.get_or_init(|| Runtime::new().expect("failed to create tokio runtime"))
}