]> Cypherpunks.ru repositories - gostls13.git/commitdiff
time: update current time comment
authorastraw99 <wangchengiscool@gmail.com>
Mon, 16 Aug 2021 09:54:40 +0000 (09:54 +0000)
committerIan Lance Taylor <iant@golang.org>
Mon, 16 Aug 2021 17:24:37 +0000 (17:24 +0000)
In the time package, the ticker and timer both send
current time to channel C, so this PR update the comment
to understand them better.

Change-Id: I99846a40bf8ef780bf0062dd84cf721b3b892a1b
GitHub-Last-Rev: 535da54b8ebd25be22289699212364df0aa49c7f
GitHub-Pull-Request: golang/go#47597
Reviewed-on: https://go-review.googlesource.com/c/go/+/340649
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>

src/time/sleep.go
src/time/tick.go

index 4f4579941469cd978ef39c0b01e0f281e3ed39f3..b467d1d589d1e70fa32914f1f3cce1f8859ae877 100644 (file)
@@ -139,12 +139,8 @@ func (t *Timer) Reset(d Duration) bool {
        return resetTimer(&t.r, w)
 }
 
+// sendTime does a non-blocking send of the current time on c.
 func sendTime(c interface{}, seq uintptr) {
-       // Non-blocking send of time on c.
-       // Used in NewTimer, it cannot block anyway (buffer).
-       // Used in NewTicker, dropping sends on the floor is
-       // the desired behavior when the reader gets behind,
-       // because the sends are periodic.
        select {
        case c.(chan Time) <- Now():
        default:
index 81d2a43f2838800bf0b1d8cc456882600fc35de3..f9522b0b754ad6c2566b0e04cb45fd856a7857b5 100644 (file)
@@ -14,9 +14,9 @@ type Ticker struct {
 }
 
 // NewTicker returns a new Ticker containing a channel that will send
-// the time on the channel after each tick. The period of the ticks is
-// specified by the duration argument. The ticker will adjust the time
-// interval or drop ticks to make up for slow receivers.
+// the current time on the channel after each tick. The period of the
+// ticks is specified by the duration argument. The ticker will adjust
+// the time interval or drop ticks to make up for slow receivers.
 // 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 {