Expand description
Async runtime with work-stealing scheduler for QuantaLang.
This module provides the async/await runtime infrastructure including:
- Work-stealing task scheduler
- Future and Task representations
- Executor and worker thread management
- Timer and I/O integration points
§Architecture
The runtime uses a work-stealing scheduler where each worker thread has its own local queue of tasks. When a worker runs out of work, it attempts to steal tasks from other workers’ queues.
┌─────────────────────────────────────────────────────────────────┐
│ Executor │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │ Worker0 │ │ Worker1 │ │ Worker2 │ │ Worker3 │ ... │
│ │ [Queue] │←→│ [Queue] │←→│ [Queue] │←→│ [Queue] │ │
│ └─────────┘ └─────────┘ └─────────┘ └─────────┘ │
│ ↓ ↓ ↓ ↓ │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ Global Queue │ │
│ └─────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘Structs§
- Async
FnMetadata - Metadata for async function code generation.
- Channel
- A bounded multi-producer multi-consumer channel.
- Context
- Context passed to futures when polling.
- Executor
- The async runtime executor.
- Executor
Config - Configuration for the executor.
- Executor
Inner - Shared executor state.
- Executor
Stats - Executor statistics.
- Join
Handle - Handle for waiting on a task to complete.
- Oneshot
- A single-use channel for one value.
- Semaphore
- An async semaphore for limiting concurrency.
- Task
- A task in the runtime.
- Timer
Entry - A timer entry.
- Timer
Wheel - Timer wheel for managing timeouts.
- Waker
- Waker for notifying the runtime that a task is ready.
- Work
Stealing Deque - A work-stealing deque for tasks.
- Worker
- Worker thread state.
Enums§
- Async
State - State machine state for an async function.
- Channel
Error - Channel operation error.
- Poll
- Poll result from a future.
- Task
State - Task state machine.
Traits§
- Future
- Simplified future trait for code generation.
Functions§
- async_
state_ machine_ layout - Generate async state machine struct layout.
- current_
task_ id - Get the current task ID.
- set_
current_ task_ id - Set the current task ID.
Type Aliases§
- TaskId
- Unique task identifier.