The piece that runs your futures
An async function does nothing on its own. It produces a future, a value that represents work not yet finished. The executor is the runtime component that takes futures and drives them to completion.
How polling works
The executor calls poll on a future. The future runs until it either finishes or hits an await it cannot satisfy yet.
- If the future returns Ready, its result is available and the executor is done with it.
- If it returns Pending, the future has parked itself and the executor moves on to other work.
The executor keeps a ready queue of tasks that can make progress. It pulls one, polls it, and either completes it or sets it aside until it becomes ready again.
Why it does not busy loop
A naive runtime would poll pending futures over and over, burning CPU. A real executor only re polls a task when it is told the task can progress, which is the job of the waker covered separately. Until then the task sleeps and the core is free.
Key idea
The executor drives futures by polling tasks from a ready queue, completing the ones that return Ready and parking those that return Pending so the core stays free.