Skip to content

Async runtime (executor and reactor)

Category: Scheduling · Status: stub · Lessons: chapter 06, Async (planned)

One line: The library that drives async tasks: an executor that polls the tasks that can make progress, and a reactor that wakes them when the I/O they wait for is ready.

Also called: executor, reactor, tokio, asyncio event loop.

How it connects

flowchart LR
  n_async_runtime["Async runtime (executor and reactor)"]
  n_event_loop["Event loop"]
  n_io_multiplexing["I/O multiplexing"]
  n_polling["Polling"]
  n_work_stealing["Work stealing"]
  n_async_runtime -->|uses| n_event_loop
  n_async_runtime -->|uses| n_io_multiplexing
  n_async_runtime -->|uses| n_polling
  n_async_runtime -->|uses| n_work_stealing
  classDef center stroke-width:3px
  class n_async_runtime center
  classDef outside stroke-dasharray: 4 3
  class n_event_loop,n_io_multiplexing,n_polling,n_work_stealing outside

In each language

Rust Not in the standard library: Tokio ↗, whose #[tokio::main] starts one, is the common choice
Python asyncio.run runs a coroutine in an event loop that it manages, and returns the result
Kotlin runBlocking bridges regular blocking code to suspending code, blocking its thread until the coroutine completes

Where to read more