Skip to main content

spawn

Function spawn 

Source
pub fn spawn<F>(f: F) -> JoinHandle<<F as Future>::Output> ⓘ
where F: Future + 'static,
Expand description

Spawns a future on the current Tokio local task set and returns its join handle.

The future and output need not be Send. The current system’s TaskCallbacks are applied. Dropping the handle detaches the task unless cancel_on_drop is enabled. The local task set must keep being driven for it to make progress. An ntex system is not required, without one no task callbacks are applied.

§Panics

Panics outside a Tokio context that supports local spawning, such as a LocalSet.