Tokio: Orientation
Tokio turns Rust futures into a running asynchronous system. Its runtime bundles task scheduling, operating-system I/O readiness, timers, and a separate pool for blocking functions.
spawn future → runnable task queue → poll
├─ Ready(output) → JoinHandle
└─ Pending + Waker
↓
I/O driver or timer fires
↓
wake → runnable queue
Design thesis
Tokio separates “may this future make progress?” from “which thread should poll it?”, connecting resource readiness to cooperative task scheduling with wakers.
Tokio does not run an async fn continuously in the background. Calling it
creates a future. A task repeatedly polls that future only after it is spawned
and initially scheduled or later woken.
Four terms to keep separate
- Asynchrony: work can pause at
Pendingand resume after a wake-up. - Concurrency: many tasks can be in progress, even on one runtime thread.
- Parallelism: a multi-thread runtime can poll different tasks on several worker threads simultaneously.
- Blocking: an OS thread cannot run other work until an operation returns.
This chapter goes below the safe public API into Tokio’s unsafe task core.
The goal is not to copy it casually. It is to understand which invariants a
production executor must uphold so ordinary application code stays safe.