Hello golang-dev@googlegroups.com, I'd like you to review this change to https://code.google.com/p/go
LGTM On Jul 19, 2012 11:47 AM, <r@golang.org> wrote: > Reviewers: golang-dev_googlegroups.com, > > Message: > Hello golang-dev@googlegroups.com, > > I'd like you to review this change to > https://code.google.com/p/go > > > Description: > sync: mention that WaitGroup.Add panics > Fixes issue 3839. > > Please review this at http://codereview.appspot.com/**6428053/<http://codereview.appspot.com/6428053/> > > Affected files: > M src/pkg/sync/waitgroup.go > M src/pkg/sync/waitgroup_test.go > > > Index: src/pkg/sync/waitgroup.go > ==============================**==============================**======= > --- a/src/pkg/sync/waitgroup.go > +++ b/src/pkg/sync/waitgroup.go > @@ -32,10 +32,11 @@ > > // Add adds delta, which may be negative, to the WaitGroup counter. > // If the counter becomes zero, all goroutines blocked on Wait() are > released. > +// If the counter goes negative, Add panics. > func (wg *WaitGroup) Add(delta int) { > v := atomic.AddInt32(&wg.counter, int32(delta)) > if v < 0 { > - panic("sync: negative WaitGroup count") > + panic("sync: negative WaitGroup counter") > } > if v > 0 || atomic.LoadInt32(&wg.waiters) == 0 { > return > Index: src/pkg/sync/waitgroup_test.go > ==============================**==============================**======= > --- a/src/pkg/sync/waitgroup_test.**go > +++ b/src/pkg/sync/waitgroup_test.**go > @@ -50,7 +50,7 @@ > func TestWaitGroupMisuse(t *testing.T) { > defer func() { > err := recover() > - if err != "sync: negative WaitGroup count" { > + if err != "sync: negative WaitGroup counter" { > t.Fatalf("Unexpected panic: %#v", err) > } > }() > > >
*** Submitted as http://code.google.com/p/go/source/detail?r=05f9fa32500a *** sync: mention that WaitGroup.Add panics Fixes issue 3839. R=golang-dev, bradfitz CC=golang-dev http://codereview.appspot.com/6428053