aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2016-11-11 10:11:19 -0500
committerRuss Cox <rsc@golang.org>2016-11-11 19:25:24 +0000
commitfabb4115ed311ec4af19f87c2334e38497dbb8d0 (patch)
tree85a249ec906f250d6f9e837985dbc1cf17ffeb13 /src
parent84ded8ba8a0233a7f38e3c777dc1c213f98d00a2 (diff)
downloadgo-fabb4115ed311ec4af19f87c2334e38497dbb8d0.tar.xz
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 <rsc@golang.org> Reviewed-by: Ian Gudger <igudger@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src')
-rw-r--r--src/time/sleep.go8
1 files changed, 7 insertions, 1 deletions
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")