Function compio_runtime::spawn
source · pub fn spawn<F: Future + 'static>(future: F) -> Task<F::Output> ⓘExpand description
Spawns a new asynchronous task, returning a Task for it.
Spawning a task enables the task to execute concurrently to other tasks. There is no guarantee that a spawned task will execute to completion.
let task = compio_runtime::spawn(async {
println!("Hello from a spawned task!");
42
});
assert_eq!(task.await, 42);Panics
This method doesn’t create runtime. It tries to obtain the current runtime
by Runtime::current.