Skip to main content

spawn

Function spawn 

Source
pub fn spawn<T>(future: impl Future<Output = T> + 'static) -> JoinHandle<T> 
where T: 'static,
Expand description

Spawn a task on the current runtime.

This function spawns the given future on the runtime and returns a JoinHandle that can be awaited to get the task’s output.

§Panics

Panics if called outside a runtime context.

§Examples

let handle = vibeio::spawn(async { 42 });
let result = handle.await;