Async Rust · 18 min · free with an account

Runtimes

Lesson preview · about 30%

Rust ships the async syntax but not the engine that drives it.

Core idea

std defines Future; the executor is a library decision.

Start with the idea

The language defines Future and .await; polling, timers, and I/O readiness come from a runtime you choose, such as tokio or async-std. That keeps async usable on an embedded target with no allocator, at the cost of one decision you have to make per project.

Rust's language and standard library define Future and .await, but a program needs an executor to poll futures and often a runtime to provide timers, sockets, and task spawning. Tokio is a common choice, but an async function is not inherently tied to one runtime. A library should be clear about whether it uses runtime-specific I/O types or exposes runtime-neutral futures. The decision affects how easily callers can integrate it.

The runtime schedules ready tasks; it cannot make blocking code magically nonblocking. A synchronous file operation or long CPU loop inside an async task can occupy an executor worker and delay unrelated tasks.

Keep learning, for free

The rest of this lesson is waiting for you.

Create a free account to read the complete explanation, see the infographic, explore the code, and try the exercises. All 742 lessons and algorithm steps are included.

No payment details. Your account opens the complete Academy.

← All lessons in Concurrency & Async