1use std::future::Future;
2
3#[cfg(any(not(target_arch = "wasm32"), target_os = "wasi"))]
9#[track_caller]
10pub fn spawn<F: Future<Output = ()> + Send + 'static>(f: F) {
11 #[cfg(feature = "tracing")]
12 let f = tracing::Instrument::in_current_span(f);
13 tokio::task::spawn(f);
14}
15
16#[cfg(all(target_arch = "wasm32", not(target_os = "wasi")))]
17#[track_caller]
18pub fn spawn<F: Future<Output = ()> + 'static>(f: F) {
19 #[cfg(feature = "tracing")]
20 let f = tracing::Instrument::in_current_span(f);
21 wasm_bindgen_futures::spawn_local(f);
22}