Skip to content
Select theme

Async fundamentals

async in Rust is not threads, and the runtime is not free. A future is a state machine that does nothing until something polls it, which explains almost every beginner surprise: an async fn that never runs, an await that blocks the wrong thing, a timeout that does not stop the work.

Read this chapter before the Tokio one.

Nothing published in this chapter yet — all 11 articles are still to come.

Coming up (11)
  • What is async in Rust?state machines, not threads
  • How to call an async functionnothing runs until it is awaited
  • What is a Future?poll, Pending, and Ready
  • What is an async executor?the runtime you have to bring yourself
  • What does block_on do?driving a future from a sync main
  • How to await several futures at oncejoin!, try_join!, and the ordering that matters
  • How to add a timeoutwrapping the future, and the work that keeps running
  • What is a Stream?an async iterator, without the trait
  • What are async traits?native in Rust 1.75, and the dyn limit
  • How to cancel a taskdropping the handle is the cancellation
  • When should you not use async?threads, blocking IO, and small tools