-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Description
Proposed new functions for NewTickerStartingAt and RuntimeStarted in time
NewTickerStartingAt - The function NewTicker has been limiting users as often I need a NewTicker that starts ticking at a specific time. I find many times I was wrapping this timer call in an anonymous function with sleep then a NewTicker. To avoid this redundancy for others and myself, I'd like to expose the interface to the underlying timer interface with both inputs: period duration and start time for the initial tick. For example; an initial ticket the fires immediately use NewTickerStartingAt(duration, time.Now()). If the proposed time is in the past it immediately fires and then syncs up on that interval. Another example: the duration is set to a minute, and then starting at a time is also on a minute mark, the result is ticked at the minute. Times passing over a leap second is a known limitation, but this is also experienced by NewTicker
RuntimeStarted - is useful to have as a way of looking up the runtime. I know something similar can be created by storing this value via an init() function, but having a static value in the time library can be useful in many places. Such as metrics. Efficiency is achieved by storing the structure values in start_ local variables so subsequent calls will retrieve the exact same time.
Proposal:
https://go-review.googlesource.com/c/proposal/+/281453/2
View pull request: here:
#43488
View pull request discussion here:
https://go-review.googlesource.com/c/go/+/281332
I need a function to start a timer at an arbitrary time. This is related to and also resolves issues:
#41885
#17601
Metadata
Metadata
Assignees
Labels
Type
Projects
Status