diff --git a/examples/complete/main.go b/examples/complete/main.go index 887a004..4189a25 100644 --- a/examples/complete/main.go +++ b/examples/complete/main.go @@ -39,12 +39,12 @@ defer wg.Done() max := 200 * time.Millisecond for i := 0; i < total; i++ { - time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10) - b.Increment() if b.ID() == 1 && i == 42 { b.Complete() return } + time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10) + b.Increment() } }() } diff --git a/examples/panic/main.go b/examples/panic/main.go index b50ac94..f01df89 100644 --- a/examples/panic/main.go +++ b/examples/panic/main.go @@ -21,7 +21,9 @@ name := fmt.Sprintf("b#%02d:", i) bar := p.AddBar(100, mpb.BarID(i), mpb.PrependDecorators( func(s *decor.Statistics, _ chan<- int, _ <-chan int) string { - if s.ID == 2 && s.Current == 42 { + // s.Current == 42 may never happen, if sleep btw increments is + // too short, thus using s.Current >= 42 + if s.ID == 1 && s.Current >= 42 { panic(wantPanic) } return name @@ -31,7 +33,7 @@ go func() { defer wg.Done() for i := 0; i < 100; i++ { - time.Sleep(10 * time.Millisecond) + time.Sleep(50 * time.Millisecond) bar.Increment() } }() diff --git a/examples/remove/main.go b/examples/remove/main.go index 12d5bef..babf54d 100644 --- a/examples/remove/main.go +++ b/examples/remove/main.go @@ -39,12 +39,12 @@ defer wg.Done() max := 200 * time.Millisecond for i := 0; i < total; i++ { - time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10) - b.Increment() if b.ID() == 1 && i == 42 { p.RemoveBar(b) return } + time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10) + b.Increment() } }() }