Commit bc64c078 authored by Andrew Gerrand's avatar Andrew Gerrand

sync: be more explicit in WaitGroup docs

Fixes #8543.

LGTM=dvyukov, r
R=rsc, r
CC=dvyukov, golang-codereviews
https://golang.org/cl/123580043
parent f129370b
...@@ -37,10 +37,13 @@ type WaitGroup struct { ...@@ -37,10 +37,13 @@ type WaitGroup struct {
// If the counter becomes zero, all goroutines blocked on Wait are released. // If the counter becomes zero, all goroutines blocked on Wait are released.
// If the counter goes negative, Add panics. // If the counter goes negative, Add panics.
// //
// Note that calls with positive delta must happen before the call to Wait, // Note that calls with a positive delta that occur when the counter is zero
// or else Wait may wait for too small a group. Typically this means the calls // must happen before a Wait. Calls with a negative delta, or calls with a
// to Add should execute before the statement creating the goroutine or // positive delta that start when the counter is greater than zero, may happen
// other event to be waited for. See the WaitGroup example. // 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) { func (wg *WaitGroup) Add(delta int) {
if raceenabled { if raceenabled {
_ = wg.m.state // trigger nil deref early _ = wg.m.state // trigger nil deref early
......
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