From: Russ Cox Date: Fri, 11 Nov 2016 15:11:19 +0000 (-0500) Subject: time: update Timer.Stop doc to account for AfterFunc X-Git-Tag: go1.8beta1~197 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=fabb4115ed311ec4af19f87c2334e38497dbb8d0;p=gostls13.git time: update Timer.Stop doc to account for AfterFunc Fixes #17600. Change-Id: I7aa0eb0dd959da031b6039b51f07db668d4fb468 Reviewed-on: https://go-review.googlesource.com/33131 Run-TryBot: Russ Cox Reviewed-by: Ian Gudger Reviewed-by: Ian Lance Taylor --- diff --git a/src/time/sleep.go b/src/time/sleep.go index 8e5c8254f1..4b01404896 100644 --- a/src/time/sleep.go +++ b/src/time/sleep.go @@ -55,7 +55,7 @@ type Timer struct { // Stop does not close the channel, to prevent a read from the channel succeeding // incorrectly. // -// To prevent the timer firing after a call to Stop, +// To prevent a timer created with NewTimer from firing after a call to Stop, // check the return value and drain the channel. // For example, assuming the program has not received from t.C already: // @@ -65,6 +65,12 @@ type Timer struct { // // This cannot be done concurrent to other receives from the Timer's // channel. +// +// For a timer created with AfterFunc(d, f), if t.Stop returns false, then the timer +// has already expired and the function f has been started in its own goroutine; +// Stop does not wait for f to complete before returning. +// If the caller needs to know whether f is completed, it must coordinate +// with f explicitly. func (t *Timer) Stop() bool { if t.r.f == nil { panic("time: Stop called on uninitialized Timer")