enfync/builtin/wasm/spawner_impls.rs
1//local shortcuts
2use crate::*;
3
4//third-party shortcuts
5
6//standard shortcuts
7
8
9//-------------------------------------------------------------------------------------------------------------------
10
11/// Implements `OneshotSpawner` for `wasm` runtimes (spawns wasm tasks).
12#[derive(Debug, Clone, Default)]
13pub struct WasmIOSpawner;
14
15impl OneshotSpawner for WasmIOSpawner
16{
17 fn spawn<F>(&self, task: F)
18 where
19 F: std::future::Future<Output = ()> + Send + 'static,
20 {
21 wasm_bindgen_futures::spawn_local(
22 async move {
23 task.await;
24 }
25 );
26 }
27}
28
29impl From<builtin::wasm::WASMHandle> for WasmIOSpawner { fn from(_: builtin::wasm::WASMHandle) -> Self { WasmIOSpawner{} } }
30
31//-------------------------------------------------------------------------------------------------------------------