Skip to main content

spawn

Function spawn 

Source
pub fn spawn<T, F>(name: &str, future: F) -> JoinHandle<T> 
where F: Future<Output = T> + Send + 'static, T: Send + 'static,
Expand description

Spawn a named task onto the executor currently running on this thread.

The returned JoinHandle mirrors tokio semantics: awaiting it yields the task’s output (or a JoinError if the task was aborted or panicked), dropping it detaches the task, and JoinHandle::abort cancels it.

§Panics

Panics when called outside Executor::block_on, mirroring tokio::spawn outside a runtime.