You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Thank you for raising this issue. Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.
pschou
changed the title
Need a NewTicker to start at an arbitrary time and a way to get the process start time
time: Need a NewTicker to start at an arbitrary time and a way to get the process start time
Jan 5, 2021
ianlancetaylor
changed the title
time: Need a NewTicker to start at an arbitrary time and a way to get the process start time
proposal: time: NewTickerStartingAt and RuntimeStarted
Jan 5, 2021
It will be easier to understand this proposal if you can update the initial comment to provide a brief description of the functions you propose adding. Thanks.
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
The text was updated successfully, but these errors were encountered: