-
Notifications
You must be signed in to change notification settings - Fork 58
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
Add support for fake tickers #8
Conversation
Hello Jon, |
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.
The code looks good to me. It seems to be missing a time.Tick(d)
function, but that is only a wrapper around NewTicker(d).Chan()
at this point.
@@ -12,6 +12,7 @@ type Clock interface { | |||
Sleep(d time.Duration) | |||
Now() time.Time | |||
Since(t time.Time) time.Duration | |||
NewTicker(d time.Duration) Ticker |
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 is technically not following the exact definition of NewTicker
from the stdlib. There it is func NewTicker(d Duration) *Ticker
. But I don't know if this is a concern
edit: I just realized that Ticker
is an interface. Sorry about the confusion
LGTM. Sorry about the horrendous delay. |
I spend a little time on extending your library to add support for fake tickers.
Currently this requires surrounding the Advance() calls with BlockUntil() to make sure that the ticker can go to sleep before Advance() is called and afterwards wake up before we start consuming ticks.
Let me know what you think.