aboutsummaryrefslogtreecommitdiff
path: root/src/pkg
diff options
context:
space:
mode:
authorAndrew Gerrand <adg@golang.org>2014-08-22 09:53:44 +1000
committerAndrew Gerrand <adg@golang.org>2014-08-22 09:53:44 +1000
commitbc64c078259b97392c2a9d5ee6bda75ae3971579 (patch)
treea7c80b6e692c3f3e2fbeed512b4a93ff52300b6e /src/pkg
parentf129370b3e5d53a384281503f658b3a5b115fbd5 (diff)
downloadgo-bc64c078259b97392c2a9d5ee6bda75ae3971579.tar.xz
sync: be more explicit in WaitGroup docs
Fixes #8543. LGTM=dvyukov, r R=rsc, r CC=dvyukov, golang-codereviews https://golang.org/cl/123580043
Diffstat (limited to 'src/pkg')
-rw-r--r--src/pkg/sync/waitgroup.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/pkg/sync/waitgroup.go b/src/pkg/sync/waitgroup.go
index 4c64dca393..92cc57d2cc 100644
--- a/src/pkg/sync/waitgroup.go
+++ b/src/pkg/sync/waitgroup.go
@@ -37,10 +37,13 @@ type WaitGroup struct {
// If the counter becomes zero, all goroutines blocked on Wait are released.
// If the counter goes negative, Add panics.
//
-// Note that calls with positive delta must happen before the call to Wait,
-// or else Wait may wait for too small a group. Typically this means the calls
-// to Add should execute before the statement creating the goroutine or
-// other event to be waited for. See the WaitGroup example.
+// Note that calls with a positive delta that occur when the counter is zero
+// must happen before a Wait. Calls with a negative delta, or calls with a
+// positive delta that start when the counter is greater than zero, may happen
+// at any time.
+// Typically this means the calls to Add should execute before the statement
+// creating the goroutine or other event to be waited for.
+// See the WaitGroup example.
func (wg *WaitGroup) Add(delta int) {
if raceenabled {
_ = wg.m.state // trigger nil deref early