-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Scheduler that manually advances time #24243
Conversation
bbedcb2
to
d28c4c8
Compare
|
||
class ManualTimerSpec extends TestKit() with ManualTime with WordSpecLike { | ||
//#manual-scheduling-simple | ||
"A timer" must { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks nice
Test PASSed. |
* For testing: scheduler that does not look at the clock, but must be progressed manually by calling `timePasses`. | ||
* | ||
* This is not entirely realistic: jobs will be executed on the test thread instead of using the `ExecutionContext`, but does | ||
* allow for faster and less timing-sensitive specs.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couldn't we still have them run on whatever execution context they want through futures, but block time Passes
on the futures completion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would not really help, as the resulting behavior would still be different from what would happen when the jobs were executed in 'real time' parallel. I'll make the wording somewhat less scary.
Test FAILed. |
Test FAILed. |
* We will not add a dilation factor to this amount, since the scheduler API also does not apply dilation. | ||
* If you want the amount of time passed to be dilated, apply the dilation before passing the delay to | ||
* this method. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"This will execute all outstanding jobs on the calling thread before returning" or such?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍. (It will also execute any jobs that are scheduled to be executed within the specified period by those outstanding jobs, but that might be a subtlety that doesn't really belong in the scaladoc here)
Test PASSed. |
Test PASSed. |
First version for review. More tests, docs and Java examples still TBD.
#24243 (comment) for some discussion on what to do instead
b261dd9
to
55c0faf
Compare
Test PASSed. |
Test PASSed. |
Test PASSed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* Don't apply dilation to scheduler parameter * Clarify ExecutionContext usage * Clarify comment on timePasses * Make ExplicitlyTriggeredScheduler internals private * List currently scheduled tasks in one log message * Execute immediately if (initialDelay <= Duration.Zero) * Don't reschedule if scheduled task fails * Be more efficient about logging * Widen `timePasses` delay for now akka#24243 (comment) for some discussion on what to do instead * Remove mechanism for mixing in config from a test trait
#24150
First version for early review. More tests, docs and Java examples still TBD.