You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR adds startup-time plans: one-shot lifecycle work that runs at the
effective simulation start time—either the configured start time or 0.0—
before regular plans.
Add Context::add_startup_plan and Context::add_startup_plan_with_phase.
Expose startup-plan scheduling through ContextBase and PluginContext.
Expand the event-loop state machine to model startup, regular execution,
shutdown, and abort/resume transitions explicitly.
Add a dedicated startup queue with shared plan IDs, cancellation, and
profiling support.
Update the Context API documentation to describe the full simulation
lifecycle.
Behavior
Startup-time plans:
Run once at the effective simulation start time before any regular plan.
Follow ExecutionPhase ordering, then insertion order within each phase.
Yield to queued callbacks, which retain priority over plan selection.
May schedule additional startup-time plans while startup is still active.
Can be canceled through their PlanId.
Resume on a later execute call when startup is interrupted by abort.
Finish draining before shutdown proceeds when shutdown is requested during
startup.
The reason will be displayed to describe this comment to others. Learn more.
The issue described how to expand the event loop state machine in a way that expands it to startup time. This implementation uses a separate state tracking mechanism that obfuscates which states and transitions are possible. If there is a reason, I need an explanation.
Also, don't let the LLM factor out single lines of code into useless helpers. Introducing DistinguishedQueue, add_distinguished_plan, and pop_next_distinguished is pretty egregious.
The issue described how to expand the event loop state machine in a way that expands it to startup time. This implementation uses a separate state tracking mechanism that obfuscates which states and transitions are possible. If there is a reason, I need an explanation.
Also, don't let the LLM factor out single lines of code into useless helpers. Introducing DistinguishedQueue, add_distinguished_plan, and pop_next_distinguished is pretty egregious.
The separate startup-progress field is gone, and the lifecycle is now represented by a single explicit EventLoopStatus state machine. I also removed DistinguishedQueue, add_distinguished_plan, and pop_next_distinguished, and inlined the queue-specific logic. I added tests for abort and shutdown during startup, preserving pending shutdown across an abort, and single-step state transitions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds startup-time plans: one-shot lifecycle work that runs at the
effective simulation start time—either the configured start time or
0.0—before regular plans.
Context::add_startup_planandContext::add_startup_plan_with_phase.ContextBaseandPluginContext.shutdown, and abort/resume transitions explicitly.
profiling support.
ContextAPI documentation to describe the full simulationlifecycle.
Behavior
Startup-time plans:
ExecutionPhaseordering, then insertion order within each phase.PlanId.executecall when startup is interrupted byabort.startup.