mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
time: in NewTicker, document that the 1st tick comes after d
Fixes #42245 Change-Id: I3b298ab6be65569389873d68bd3c6e49cf892c69 Reviewed-on: https://go-review.googlesource.com/c/go/+/265818 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Rob Pike <r@golang.org> Trust: Alberto Donizetti <alb.donizetti@gmail.com>
This commit is contained in:
parent
041a4e4c34
commit
bcfaeca58c
1 changed files with 6 additions and 5 deletions
|
|
@ -13,11 +13,12 @@ type Ticker struct {
|
||||||
r runtimeTimer
|
r runtimeTimer
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTicker returns a new Ticker containing a channel that will send the
|
// NewTicker returns a new Ticker containing a channel that will send
|
||||||
// time with a period specified by the duration argument.
|
// the time on the channel after each tick. The period of the ticks is
|
||||||
// It adjusts the intervals or drops ticks to make up for slow receivers.
|
// specified by the duration argument. The ticker will adjust the time
|
||||||
// The duration d must be greater than zero; if not, NewTicker will panic.
|
// interval or drop ticks to make up for slow receivers.
|
||||||
// Stop the ticker to release associated resources.
|
// The duration d must be greater than zero; if not, NewTicker will
|
||||||
|
// panic. Stop the ticker to release associated resources.
|
||||||
func NewTicker(d Duration) *Ticker {
|
func NewTicker(d Duration) *Ticker {
|
||||||
if d <= 0 {
|
if d <= 0 {
|
||||||
panic(errors.New("non-positive interval for NewTicker"))
|
panic(errors.New("non-positive interval for NewTicker"))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue