-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
Milestone
Description
by kballard:
The interface for time.Ticker makes it impossible to determine if any ticks have been skipped if the period is small. The difficulty lies in the fact that the underlying timer has a "when" field that isn't exposed, and the client of the ticker can't possibly know exactly what the value of "when" is. On each tick it's given the time that the tick was calculated at, but without the "when" field, determining if any ticks have been skipped is not possible with 100% accuracy. This is, of course, only a problem for very small periods. Rather than exposing the "when" field, it's probably much simpler and better to simply create a second constructor that takes a Time and a Duration instead of just a Duration. This Time is used as the initial "when". Not only does this make the code for detecting skipped ticks rather trivial, it also allows for more flexibility in timer creation for clients that need that.