Skip to main content

Module async_rt

Module async_rt 

Source
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§

AsyncFnMetadata
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.
ExecutorConfig
Configuration for the executor.
ExecutorInner
Shared executor state.
ExecutorStats
Executor statistics.
JoinHandle
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.
TimerEntry
A timer entry.
TimerWheel
Timer wheel for managing timeouts.
Waker
Waker for notifying the runtime that a task is ready.
WorkStealingDeque
A work-stealing deque for tasks.
Worker
Worker thread state.

Enums§

AsyncState
State machine state for an async function.
ChannelError
Channel operation error.
Poll
Poll result from a future.
TaskState
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.