Skip to main content

spawn

Function spawn 

pub fn spawn<F>(future: F) -> JoinHandle<<F as Future>::Output> 
where F: Future + Send + 'static, <F as Future>::Output: Send + 'static,
Available on crate feature std only.
Expand description

Spawn a future on the current tokio runtime.

Drop-in replacement for tokio::spawn for tasks that intentionally live outside graceful shutdown (background workers, detached drivers). Prefer Executor::spawn_task for work that should be awaited on shutdown.

When the dial9 feature is enabled this routes through dial9::spawn, which wraps the future with wake-event tracking on a traced runtime and falls through to plain tokio::spawn otherwise. With the feature disabled this is a direct call to tokio::spawn.

§Panics

Panics if called from outside a tokio runtime context, same as tokio::spawn.