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.
compio_runtime::block_on(async {
let task = compio_runtime::spawn(async {
println!("Hello from a spawned task!");
42
});
assert_eq!(task.await, 42);
})