From: Shenghou Ma Date: Thu, 8 Nov 2012 15:25:48 +0000 (+0800) Subject: time: clarify why timer.Stop and ticker.Stop don't close the channel X-Git-Tag: go1.1rc2~1922 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=48b739caacaf8e63b5c420218704b6ce58eac0af;p=gostls13.git time: clarify why timer.Stop and ticker.Stop don't close the channel R=golang-dev, r CC=golang-dev https://golang.org/cl/6818106 --- diff --git a/src/pkg/time/sleep.go b/src/pkg/time/sleep.go index 27820b0eaa..657e254103 100644 --- a/src/pkg/time/sleep.go +++ b/src/pkg/time/sleep.go @@ -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) } diff --git a/src/pkg/time/tick.go b/src/pkg/time/tick.go index 8e43559048..b92c339c02 100644 --- a/src/pkg/time/tick.go +++ b/src/pkg/time/tick.go @@ -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) }