async task
A future handed to the runtime to run on its own, like a very light thread.
tokio::spawn turns a future into a task scheduled independently and returns a JoinHandle; many thousands of tasks can share a few worker threads.
Loading interactive…
Examples
tokio::spawn(read_station("harbor", 300))returns aJoinHandle; awaiting it gives aResult, so a task that panics shows up asErrinstead of crashingmain.