Skip to main content

spawn

Function spawn 

Source
pub fn spawn<F>(future: F) -> TaskHandle
where F: Future<Output = ()> + Send + 'static,
Expand description

Spawn a future on the runtime, returning a handle to the running task.

  • Native: tokio::spawn (runs on Tokio thread pool, requires Send).
  • WASM: wasm_bindgen_futures::spawn_local (runs on the microtask queue, no Send requirement).

Ignoring the handle detaches the task: nothing can then stop it or wait for it. Register it with crate::tasks::TaskRegistry instead, so database shutdown can stop it before the runtime goes away.