Repository navigation
Conversation
Signed-off-by: Ym <173550318+MaxonT@users.noreply.github.com>
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
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.waitutility from #450. Thanks to @mkorbel1 for the sketch in discussion #449; the implementation follows it.Description & Motivation
Simulator.wait(int delay)returns aFuture<void>that completes oncedelayunits of simulation time have passed, so a flow can writeawait Simulator.wait(10);instead of building aCompleterand callingregisterActionitself. It is a thin wrapper overregisterAction(Simulator.time + delay, ...), so it follows the same rules: a negative delay throws aSimulatorException, and the future only completes while the simulation is running. I used the namewaitbecause that is what #450 proposes; the discussion also floateddelay, 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:
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; andwait(-1)throws aSimulatorException.dart test test/simulator_test.dart: 27 of 27 pass.dart analyzeon the two changed files reports no issues.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.