Loading tutorials
async fn does not run when you call it. It builds a value that can run later, and .await is the point where that value gets driven forward. This chapter explains what that means in practice, so that later chapters on polling, runtimes and tasks have something solid to build on.5 min readasync fn and .await. It also assumes you can run a Cargo project. You don't need Tokio here. The examples use only the standard library, so you can see what any runtime must do for you.5 min readasync fn and .await do, and that a future is a value with a poll method returning Poll::Ready or Poll::Pending. You should also be comfortable with Arc, traits and closures. Here we look at what has to exist around a future before it makes progress, and5 min read#[tokio::main] attribute does for you, and the errors people hi5 min read#[tokio::main] and spawn tasks with tokio::spawn. It also assumes you know that spawned tasks must be Send + 'static. You should be comfortable with Cargo features and with std::thread.5 min readtokio::spawn: what a task is, when it starts running, how it differs from a plain future, and what happens when you drop its handle. It assumes you know ownership and closures, you can add a crate with Cargo, and you have a runtime started with #[tokio::main]. The Send and 5 min readtokio::spawn as shown in the previous chapter. It explains two compiler errors that most Tokio beginners hit, and why they exist.4 min readtokio::spawn, that you understand Send + 'static bounds, and that you know the basics of Result and ? in Rust. Here you will learn what a JoinHandle gives you, how task failures surface, and how to collect results from many tasks.5 min read#[tokio::main] and tokio::spawn. Here you will see how Tokio performs I/O and waits without blocking a thread, and how to put a time limit on any operatio5 min readasync fn code, run it under #[tokio::main], and use tokio::spawn and JoinHandle. It also assumes you know that .await on a future suspends only the current task. It covers how to wait on several futures from one task, and the cases where you would p5 min readtokio::spawn, you know why those tasks must be Send + 'static, and you are comfortable with Arc and ownership moves into async move blocks. Here you will learn to connect tasks with Tokio's channels, so they can communicate without sharing locked5 min readArc and Mutex from std, and how tokio::spawn works, including why spawned futures must be Send + 'static. By the end you should be able to pick between a std mutex, a Tokio mutex, an RwLock, atomics, and message passing, and a6 min readasync fn code, know what tokio::spawn and .await do, and understand that a future only makes progress when the runtime polls it. It also assumes you have seen Send and 'static bounds on spawned tasks.5 min readselect!, and read JoinHandle results. These are covered in the earlier chapters on tasks and on join!/select!. Here you will learn what happens to a future that never finishes, and how to write code that survives it.4 min readJoinHandle results. It also assumes you know Tokio channels, select!, and the idea that dropping a future cancels it. Here you combine those pieces so a service stops without losing work.4 min readasync fn code, know what tokio::spawn does, and understand why a spawned task must be Send + 'static. Everything else is built up from there.4 min readtokio::spawn, channels and timeout, and you know how Cargo test modules work. The aim is tests that are fast, deterministic and unable to hang forever.4 min read