longbridge/runtime.rs
1//! Global tokio runtime shared across all contexts and language bindings.
2
3use std::sync::LazyLock;
4
5use tokio::runtime::Runtime;
6
7pub(crate) static RUNTIME: LazyLock<Runtime> = LazyLock::new(|| {
8 tokio::runtime::Builder::new_multi_thread()
9 .enable_all()
10 .build()
11 .expect("create tokio runtime")
12});
13
14/// Returns a handle to the global Longbridge tokio runtime.
15///
16/// Used internally by language bindings to schedule async tasks.
17#[doc(hidden)]
18pub fn runtime_handle() -> tokio::runtime::Handle {
19 RUNTIME.handle().clone()
20}