Expand description
Async executor: single-threaded (default) and multi-threaded (opt-in).
§Single-threaded run loop (default)
block_on(future)
└─ Executor::run_loop
├─ LocalQueue (LIFO ring, 256 slots)
├─ GlobalQueue (Mutex<VecDeque> — waker injection)
└─ Reactor (kqueue/epoll — parks when no work is ready)§Multi-threaded run loop (opt-in via RuntimeBuilder::worker_threads(n))
block_on_multi(future, n_workers)
├─ worker 0 (main thread) — polls root future + runs tasks
├─ worker 1..N-1 (spawned threads) — steal and run tasks
└─ GlobalQueue + WorkStealingPool shared across all workersSingle-threaded mode is the default. Multi-thread is explicitly opt-in.
Modules§
- scheduler
- Per-core task queues:
LocalQueue(ring buffer) +GlobalQueue(mutex deque). - task
- Task lifecycle types:
TaskHeader,Task,JoinHandle. - task_
local - Task-local storage for async contexts.
- waker
- Custom
RawWakerVTableimplementation. - work_
stealing - Opt-in work-stealing layer.
- worker
- Per-worker state for the multi-threaded executor.
Structs§
- Executor
- Per-thread async executor (single-threaded mode).
Functions§
- block_
on - Drive
futureto completion on the current thread, returning its output. - block_
on_ multi - Drive
futureto completion usingnum_workersOS threads. - block_
on_ with_ spawn - Drive
futureto completion withspawn()available in the async context. - spawn
- Spawn a future onto the current thread’s executor.