Commit 48b739ca authored by Shenghou Ma's avatar Shenghou Ma

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
parent 148154b7
...@@ -36,6 +36,8 @@ type Timer struct { ...@@ -36,6 +36,8 @@ type Timer struct {
// Stop prevents the Timer from firing. // Stop prevents the Timer from firing.
// It returns true if the call stops the timer, false if the timer has already // It returns true if the call stops the timer, false if the timer has already
// expired or stopped. // expired or stopped.
// Stop does not close the channel, to prevent a read from the channel succeeding
// incorrectly.
func (t *Timer) Stop() (ok bool) { func (t *Timer) Stop() (ok bool) {
return stopTimer(&t.r) return stopTimer(&t.r)
} }
......
...@@ -39,6 +39,8 @@ func NewTicker(d Duration) *Ticker { ...@@ -39,6 +39,8 @@ func NewTicker(d Duration) *Ticker {
} }
// Stop turns off a ticker. After Stop, no more ticks will be sent. // 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() { func (t *Ticker) Stop() {
stopTimer(&t.r) stopTimer(&t.r)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment