-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
proposal: time: NewTickerStartingAt and RuntimeStarted #43503
Comments
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. For asking questions, see:
|
Yes, thank you, I have a proposal here that I want to link to this |
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. |
Change https://golang.org/cl/281332 mentions this issue: |
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: