1#[macro_export]
2macro_rules! tokio_spawn {
3 ($future:expr) => {{
4 #[cfg(target_arch = "wasm32")]
5 {
6 wasm_bindgen_futures::spawn_local($future);
7 }
8 #[cfg(not(target_arch = "wasm32"))]
9 {
10 tokio::spawn($future);
11 }
12 }};
13}
14
15#[macro_export]
16macro_rules! spawn {
17 ($block:expr) => {{
18 #[cfg(target_arch = "wasm32")]
19 {
20 wasm_bindgen_futures::spawn_local(async move { $block });
22 }
23 #[cfg(not(target_arch = "wasm32"))]
24 {
25 std::thread::spawn(move || $block);
26 }
27 }};
28}