pub struct ExecutionScheduler { /* private fields */ }Expand description
The hot-path execution scheduler.
Implementations§
Source§impl ExecutionScheduler
impl ExecutionScheduler
Sourcepub fn new(
registry: Arc<Mutex<AgentRegistry>>,
context: Arc<RwLock<Context>>,
agent_ids: &[AgentId],
) -> Self
pub fn new( registry: Arc<Mutex<AgentRegistry>>, context: Arc<RwLock<Context>>, agent_ids: &[AgentId], ) -> Self
Creates a new scheduler.
Sourcepub fn set_parallel_execution(&mut self, enabled: bool)
pub fn set_parallel_execution(&mut self, enabled: bool)
Enables or disables the parallel wave executor (default off).
Sound only when the phase’s agents correctly declare their
AgentAccess: eligible agents must
touch no World and write disjoint deck slots. With the default
(all-Exclusive) declarations every wave is a singleton, so this is
behaviourally identical to sequential execution.
Sourcepub fn set_telemetry_sender(&mut self, sender: Sender<TelemetryEvent>)
pub fn set_telemetry_sender(&mut self, sender: Sender<TelemetryEvent>)
Connects the read-only observation tunnel to the DCC. The scheduler then publishes per-agent cost samples and per-component access snapshots so the cold path can fit cost models and recommend layouts. Non-blocking: if the channel is full the sample is dropped (telemetry is best-effort).
Sourcepub fn deck_mut(&mut self) -> &mut OutputDeck
pub fn deck_mut(&mut self) -> &mut OutputDeck
Mutable access to the last frame’s [OutputDeck] — drained by the
engine at the I/O boundary (e.g. GPU submit / present).
Sourcepub fn budget_channel(&self) -> &BudgetChannel
pub fn budget_channel(&self) -> &BudgetChannel
Returns a reference to the budget channel for the DCC to send budgets.
Sourcepub fn register_plugin(&mut self, plugin: EnginePlugin)
pub fn register_plugin(&mut self, plugin: EnginePlugin)
Registers an engine plugin.
Sourcepub fn set_phase_order(&mut self, order: &[ExecutionPhase])
pub fn set_phase_order(&mut self, order: &[ExecutionPhase])
Sets the phase execution order.
Sourcepub fn insert_after(&mut self, existing: ExecutionPhase, new: ExecutionPhase)
pub fn insert_after(&mut self, existing: ExecutionPhase, new: ExecutionPhase)
Inserts a phase after an existing phase.
Sourcepub fn insert_before(&mut self, existing: ExecutionPhase, new: ExecutionPhase)
pub fn insert_before(&mut self, existing: ExecutionPhase, new: ExecutionPhase)
Inserts a phase before an existing phase.
Sourcepub fn remove_phase(&mut self, phase: ExecutionPhase)
pub fn remove_phase(&mut self, phase: ExecutionPhase)
Removes a phase from the order.
Sourcepub fn run_frame(&mut self, world: &mut World, runtime: Arc<Runtime>)
pub fn run_frame(&mut self, world: &mut World, runtime: Arc<Runtime>)
Executes the complete frame cycle.
This is called every frame by the engine loop.
§Fixed-timestep sequencing
Rendering runs at the display’s variable rate, but the simulation must advance in fixed increments to stay frame-rate independent and deterministic. The scheduler reconciles the two with an accumulator:
- Measure the real wall-clock delta since the previous frame, clamped
to [
MAX_FRAME_DELTA_SECONDS] (spiral-of-death guard), and add it tosim_accumulator. - The fixed step is the smallest
fixed_timestepdeclared by any registered agent (a single sim clock — physics owns it via its GORNA strategy). If no agent declares one, the frame degrades to the legacy “everything once per frame” path with no behaviour change. - Consume whole steps:
steps = floor(accumulator / fixed_delta), capped at [MAX_SIM_STEPS]; the remainder carries over and yields the renderinterpolation_alpha. - Run the fixed-timestep agents (TRANSFORM-phase physics)
stepstimes — a fixed-update sub-loop — so the provider advances N discrete sub-steps. Then run the regular phase loop once, excluding the agents already stepped, so OUTPUT-phase render fires a single time. - Publish the fresh
Time(delta, fixed_delta, alpha) into the runtime resource before the render phase reads it.
Substrate Flows project once per frame; the GORNA completion map, budget arbitration, and telemetry all observe each individual agent invocation (a sub-step counts as a real run, with its own cost sample).