Skip to content

Add Simulator.wait to wait for an amount of simulation time - #780

Open
MaxonT wants to merge 1 commit into
intel:mainfrom
MaxonT:contrib/450-auto
Open

MaxonT wants to merge 1 commit into
intel:mainfrom
MaxonT:contrib/450-auto

Conversation

@MaxonT

@MaxonT MaxonT commented Nov 26, 2026

Copy link
Copy Markdown

Here is a small helper for ROHD's Simulator that pauses for a given number of time units before continuing; I haven't tried it with multiple pending waits, so does that case matter to you?

This adds the Simulator.wait utility from #450. Thanks to @mkorbel1 for the sketch in discussion #449; the implementation follows it.

Description & Motivation

Simulator.wait(int delay) returns a Future<void> that completes once delay units of simulation time have passed, so a flow can write await Simulator.wait(10); instead of building a Completer and calling registerAction itself. It is a thin wrapper over registerAction(Simulator.time + delay, ...), so it follows the same rules: a negative delay throws a SimulatorException, and the future only completes while the simulation is running. I used the name wait because that is what #450 proposes; the discussion also floated delay, so I am happy to rename it.

Related Issue(s)

Resolves #450

Testing

On my machine (macOS, Dart 3.14.1), with a temporary pub workspace override because I did not have Flutter installed to resolve the full workspace:

  • Three new tests in test/simulator_test.dart: a flow that waits 5, 10 and 0 units resumes at times 5, 15 and 15; three concurrent waits (10, 10, 20) resume in that order at the right times; and wait(-1) throws a SimulatorException.
  • dart test test/simulator_test.dart: 27 of 27 pass. dart analyze on the two changed files reports no issues.
  • With the implementation changed to complete one tick late, the new tests fail (checked before I added the concurrent one).

Not verified: I did not run the rest of the test suite, the Flutter packages, or dart format (my Dart version reformats unrelated lines in these files, so I kept the new code in the surrounding style by hand).

Backwards-compatibility

Not a breaking change; it only adds a static method. The doc comment warns not to await it from inside an action passed to registerAction, since the simulator awaits each action.

Documentation

The method has a doc comment. I did not touch the user guide, which lives in the separate rohd-website repository.

Signed-off-by: Ym <173550318+MaxonT@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a utility for "waiting" a certain amount of time in the Simulator.

1 participant