1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//! Process-singleton tokio runtime owned by the crate.
//!
//! See §9.1 of `terminal_crate_plan.md`. The runtime is held behind a
//! `Mutex<Weak<Runtime>>`: the first backend spawn finds the `Weak` empty
//! and constructs a fresh `Runtime`; subsequent spawns find it upgradable
//! and clone the existing `Arc`. When the last `BackendHandle` drops, the
//! `Arc` count goes to zero and the runtime shuts down. A subsequent
//! spawn re-initialises cleanly.
use ;
pub use Runtime;
static RUNTIME: = new;
/// Get the process-singleton runtime, constructing it on first call after
/// last drop. Each [`crate::BackendHandle`] holds one of these `Arc`s for
/// the lifetime of its session, so the runtime stays alive while any
/// backend is live.
/// Adopt an externally-owned tokio runtime. The host app retains
/// responsibility for the lifecycle; the singleton is bypassed.
///
/// Implementation: M0/M1. The handle is plumbed through to per-session
/// task spawns instead of `get_or_init().spawn(...)`.