pub type Task<T> = Task<T, TaskMetadata>;Expand description
A spawned task.
A Task can be awaited to retrieve the output of its future.
Dropping a Task cancels it, which means its future won’t be polled again. To drop the
Task handle without canceling it, use detach() instead. To cancel a
task gracefully and wait until it is fully destroyed, use the cancel()
method.
§Examples
use vexide::prelude::*;
#[vexide::main]
async fn main(_peripherals: Peripherals) {
// Spawn a future onto the executor.
let task = vexide::task::spawn(async {
println!("Hello from a task!");
1 + 2
});
// Wait for the task's output.
assert_eq!(task.await, 3);
}Aliased Type§
pub struct Task<T> { /* private fields */ }