Skip to content
← All tracks

Async From First Principles

Rust

Wall 3. With no tokio available the executor lives in your own file, so `Future`, `Waker`, `Pin` and the async state machine stop being magic: you are the runtime.

This track is written for Rust, which isn't the mode you're browsing in.

0 / 19 solved · 6 articles
  1. 1. Why async exists: blocking, threads, and the cost of waiting Read
  2. 2. Not solved yet. Futures are lazy: nothing happens until you poll
  3. 3. Not solved yet. The `Future` trait: `Output`, `Poll`, and your first hand-written future
  4. 4. Not solved yet. `block_on`: the smallest thing that can run a future
  5. 5. Not solved yet. Countdown futures and the shape of `Pending`
  6. 6. `Waker` and `Context`: the wakeup contract Read
  7. 7. Not solved yet. Implementing `Wake`: a real task waker and the lost-wakeup bug
  8. 8. Not solved yet. `RawWaker` and `RawWakerVTable`: building a `Waker` with unsafe
  9. 9. What `async fn` actually compiles to Read
  10. 10. `Pin` and `Unpin`, motivated Read
  11. 11. Not solved yet. `Unpin` in practice: making `Pin<&mut Self>` usable without unsafe
  12. 12. Not solved yet. Hand-compile an `async fn` into a state machine
  13. 13. Not solved yet. `poll_fn`: a future from a closure
  14. 14. Not solved yet. Hand-rolling `join`: running two futures concurrently
  15. 15. Not solved yet. Hand-rolling `select`: racing futures and dropping the loser
  16. 16. Not solved yet. Structural pinning and safe pin projection by hand
  17. 17. Not solved yet. The minimal single-threaded executor
  18. 18. Not solved yet. Spawning, `JoinHandle`, and getting values back out
  19. 19. Not solved yet. A logical-time reactor: timers without a clock
  20. 20. Not solved yet. Fairness and starvation in your scheduler
  21. 21. Not solved yet. Cancellation is just: stop polling and drop
  22. 22. Not solved yet. Cancel safety, blocking, and locks across `.await`
  23. 23. Not solved yet. Async recursion, async closures, and streams
  24. 24. How tokio and smol build on these primitives Read
  25. 25. The function-colouring debate, honestly Read

Check yourself

4 questions · one attempt each

These do not count toward finishing the track. They are here to catch the things that are easy to read past.

0 / 4

You call a synchronous, CPU-heavy function inside an async fn. What is the consequence?

async fn handler() {
    let out = expensive_sync_work();   // 200ms, blocking
    ...
}
Question 1 of 4