]> Cypherpunks repositories - gostls13.git/commitdiff
time: clarify why timer.Stop and ticker.Stop don't close the channel
authorShenghou Ma <minux.ma@gmail.com>
Thu, 8 Nov 2012 15:25:48 +0000 (23:25 +0800)
committerShenghou Ma <minux.ma@gmail.com>
Thu, 8 Nov 2012 15:25:48 +0000 (23:25 +0800)
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/6818106

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

index 27820b0eaa76ffbb258c5429d957e03b2604929a..657e25410312767912b0f7a9b921086e20e7989f 100644 (file)
@@ -36,6 +36,8 @@ type Timer struct {
 // Stop prevents the Timer from firing.
 // It returns true if the call stops the timer, false if the timer has already
 // expired or stopped.
+// Stop does not close the channel, to prevent a read from the channel succeeding
+// incorrectly.
 func (t *Timer) Stop() (ok bool) {
        return stopTimer(&t.r)
 }
index 8e435590484465a19881abf328cb8c84587de4e9..b92c339c02a21ac7cab801b4361181ae6c73ba1d 100644 (file)
@@ -39,6 +39,8 @@ func NewTicker(d Duration) *Ticker {
 }
 
 // Stop turns off a ticker.  After Stop, no more ticks will be sent.
+// Stop does not close the channel, to prevent a read from the channel succeeding
+// incorrectly.
 func (t *Ticker) Stop() {
        stopTimer(&t.r)
 }