diff --git a/README.md b/README.md index ad916fd..413f9e1 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ ```go var wg sync.WaitGroup - // passed &wg will be accounted at p.Wait() call + // passed wg will be accounted at p.Wait() call p := mpb.New(mpb.WithWaitGroup(&wg)) total, numBars := 100, 3 wg.Add(numBars) @@ -103,7 +103,7 @@ } }() } - // Waiting for passed &wg and for all bars to complete and flush + // wait for passed wg and for all bars to complete and flush p.Wait() ``` diff --git a/_examples/barExtender/main.go b/_examples/barExtender/main.go index d4724b6..bb70f20 100644 --- a/_examples/barExtender/main.go +++ b/_examples/barExtender/main.go @@ -13,6 +13,7 @@ func main() { var wg sync.WaitGroup + // passed wg will be accounted at p.Wait() call p := mpb.New(mpb.WithWaitGroup(&wg)) total, numBars := 100, 3 wg.Add(numBars) @@ -55,6 +56,6 @@ } }() } - // wait for all bars to complete and flush + // wait for passed wg and for all bars to complete and flush p.Wait() } diff --git a/_examples/cancel/main.go b/_examples/cancel/main.go index 4025b79..1528ffd 100644 --- a/_examples/cancel/main.go +++ b/_examples/cancel/main.go @@ -16,6 +16,7 @@ defer cancel() var wg sync.WaitGroup + // passed wg will be accounted at p.Wait() call p := mpb.NewWithContext(ctx, mpb.WithWaitGroup(&wg)) total := 300 numBars := 3 @@ -49,6 +50,6 @@ } }() } - + // wait for passed wg and for all bars to complete and flush p.Wait() } diff --git a/_examples/complex/main.go b/_examples/complex/main.go index 0e96a36..a5d42f4 100644 --- a/_examples/complex/main.go +++ b/_examples/complex/main.go @@ -16,6 +16,7 @@ func main() { doneWg := new(sync.WaitGroup) + // passed doneWg will be accounted at p.Wait() call p := mpb.New(mpb.WithWaitGroup(doneWg)) numBars := 4 @@ -64,7 +65,7 @@ go newTask(doneWg, b, numBars-i) }() } - + // wait for passed doneWg and for all bars to complete and flush p.Wait() } diff --git a/_examples/differentWidth/main.go b/_examples/differentWidth/main.go index 378bb57..a358cff 100644 --- a/_examples/differentWidth/main.go +++ b/_examples/differentWidth/main.go @@ -12,9 +12,9 @@ func main() { var wg sync.WaitGroup + // passed wg will be accounted at p.Wait() call p := mpb.New( mpb.WithWaitGroup(&wg), - // container's width. mpb.WithWidth(60), ) total, numBars := 100, 3 @@ -55,6 +55,6 @@ } }() } - // wait for all bars to complete and flush + // wait for passed wg and for all bars to complete and flush p.Wait() } diff --git a/_examples/merge/main.go b/_examples/merge/main.go index beda1d4..43f8c44 100644 --- a/_examples/merge/main.go +++ b/_examples/merge/main.go @@ -12,7 +12,7 @@ func main() { var wg sync.WaitGroup - // pass &wg (optional), so p will wait for it eventually + // passed wg will be accounted at p.Wait() call p := mpb.New(mpb.WithWaitGroup(&wg), mpb.WithWidth(60)) total, numBars := 100, 3 wg.Add(numBars) @@ -59,7 +59,7 @@ } }() } - // Waiting for passed &wg and for all bars to complete and flush + // wait for passed wg and for all bars to complete and flush p.Wait() } diff --git a/_examples/multiBars/main.go b/_examples/multiBars/main.go index af2ae7a..ebca301 100644 --- a/_examples/multiBars/main.go +++ b/_examples/multiBars/main.go @@ -12,7 +12,7 @@ func main() { var wg sync.WaitGroup - // passed &wg will be accounted at p.Wait() call + // passed wg will be accounted at p.Wait() call p := mpb.New(mpb.WithWaitGroup(&wg)) total, numBars := 100, 3 wg.Add(numBars) @@ -50,6 +50,6 @@ } }() } - // Waiting for passed &wg and for all bars to complete and flush + // wait for passed wg and for all bars to complete and flush p.Wait() } diff --git a/_examples/panic/main.go b/_examples/panic/main.go index ae0b890..a843ed5 100644 --- a/_examples/panic/main.go +++ b/_examples/panic/main.go @@ -13,7 +13,11 @@ func main() { var wg sync.WaitGroup - p := mpb.New(mpb.WithWaitGroup(&wg), mpb.WithDebugOutput(os.Stderr)) + // passed wg will be accounted at p.Wait() call + p := mpb.New( + mpb.WithWaitGroup(&wg), + mpb.WithDebugOutput(os.Stderr), + ) wantPanic := strings.Repeat("Panic ", 64) numBars := 3 @@ -31,7 +35,7 @@ } }() } - + // wait for passed wg and for all bars to complete and flush p.Wait() } diff --git a/_examples/quietMode/main.go b/_examples/quietMode/main.go index 4c953d5..c3c7d71 100644 --- a/_examples/quietMode/main.go +++ b/_examples/quietMode/main.go @@ -20,7 +20,7 @@ func main() { flag.Parse() var wg sync.WaitGroup - // pass &wg (optional), so p will wait for it eventually + // passed wg will be accounted at p.Wait() call p := mpb.New( mpb.WithWaitGroup(&wg), mpb.ContainerOptional( @@ -68,7 +68,7 @@ } }() } - // Waiting for passed &wg and for all bars to complete and flush + // wait for passed wg and for all bars to complete and flush p.Wait() fmt.Println("done") } diff --git a/_examples/remove/main.go b/_examples/remove/main.go index 0f9a8f7..416df82 100644 --- a/_examples/remove/main.go +++ b/_examples/remove/main.go @@ -12,6 +12,7 @@ func main() { var wg sync.WaitGroup + // passed wg will be accounted at p.Wait() call p := mpb.New(mpb.WithWaitGroup(&wg)) total := 100 numBars := 3 @@ -49,6 +50,6 @@ } }() } - + // wait for passed wg and for all bars to complete and flush p.Wait() } diff --git a/_examples/reverseBar/main.go b/_examples/reverseBar/main.go index 6ac4378..37bcb01 100644 --- a/_examples/reverseBar/main.go +++ b/_examples/reverseBar/main.go @@ -12,10 +12,8 @@ func main() { var wg sync.WaitGroup - p := mpb.New( - // passing &wg will make p.Wait() call wait for it first - mpb.WithWaitGroup(&wg), - ) + // passed wg will be accounted at p.Wait() call + p := mpb.New(mpb.WithWaitGroup(&wg)) total, numBars := 100, 3 wg.Add(numBars) @@ -52,7 +50,7 @@ } }() } - // wait for all bars to complete and flush + // wait for passed wg and for all bars to complete and flush p.Wait() } diff --git a/_examples/spinnerBar/main.go b/_examples/spinnerBar/main.go index 368f169..a68dec2 100644 --- a/_examples/spinnerBar/main.go +++ b/_examples/spinnerBar/main.go @@ -12,8 +12,8 @@ func main() { var wg sync.WaitGroup + // passed wg will be accounted at p.Wait() call p := mpb.New( - // passing &wg will make p.Wait() call wait for it first mpb.WithWaitGroup(&wg), mpb.WithWidth(16), ) @@ -51,7 +51,7 @@ } }() } - // wait for all bars to complete and flush + // wait for passed wg and for all bars to complete and flush p.Wait() } diff --git a/_examples/spinnerDecorator/main.go b/_examples/spinnerDecorator/main.go index 4a64409..3ef27ba 100644 --- a/_examples/spinnerDecorator/main.go +++ b/_examples/spinnerDecorator/main.go @@ -12,7 +12,7 @@ func main() { var wg sync.WaitGroup - // pass &wg (optional), so p will wait for it eventually + // passed wg will be accounted at p.Wait() call p := mpb.New(mpb.WithWaitGroup(&wg), mpb.WithWidth(64)) total, numBars := 100, 3 wg.Add(numBars) @@ -44,6 +44,6 @@ } }() } - // Waiting for passed &wg and for all bars to complete and flush + // wait for passed wg and for all bars to complete and flush p.Wait() } diff --git a/_examples/stress/main.go b/_examples/stress/main.go index 1ca1a46..1b03731 100644 --- a/_examples/stress/main.go +++ b/_examples/stress/main.go @@ -16,6 +16,7 @@ func main() { var wg sync.WaitGroup + // passed wg will be accounted at p.Wait() call p := mpb.New(mpb.WithWaitGroup(&wg)) wg.Add(totalBars) @@ -44,6 +45,6 @@ } }() } - + // wait for passed wg and for all bars to complete and flush p.Wait() }