mirror of
https://github.com/hulthe/inkopslista.git
synced 2026-08-03 23:11:28 +02:00
21 lines
560 B
Rust
21 lines
560 B
Rust
#[cfg(not(target_arch = "wasm32"))]
|
|
use std::sync::LazyLock;
|
|
|
|
#[cfg(not(target_arch = "wasm32"))]
|
|
pub static RT: LazyLock<tokio::runtime::Runtime> = LazyLock::new(|| {
|
|
tokio::runtime::Builder::new_multi_thread()
|
|
.enable_all()
|
|
.build()
|
|
.expect("Failed to initialize tokio runtime")
|
|
});
|
|
|
|
#[cfg(not(target_arch = "wasm32"))]
|
|
pub fn spawn(f: impl Future<Output = ()> + Send + 'static) {
|
|
RT.spawn(f);
|
|
}
|
|
|
|
#[cfg(target_arch = "wasm32")]
|
|
pub fn spawn(f: impl Future<Output = ()> + 'static) {
|
|
wasm_bindgen_futures::spawn_local(f);
|
|
}
|