make sure both Abort cases are engaged
Vladimir Bauer
4 years ago
| 126 | 126 | *mpb.MaxWidthDistributor = makeWrapper(*mpb.MaxWidthDistributor, start, end) |
| 127 | 127 | |
| 128 | 128 | total := 80 |
| 129 | numBars := 3 | |
| 129 | numBars := 6 | |
| 130 | 130 | p := mpb.New(mpb.WithOutput(ioutil.Discard)) |
| 131 | 131 | for i := 0; i < numBars; i++ { |
| 132 | 132 | bar := p.AddBar(int64(total), |
| 140 | 140 | rng := rand.New(rand.NewSource(time.Now().UnixNano())) |
| 141 | 141 | for i := 0; i < total; i++ { |
| 142 | 142 | start := time.Now() |
| 143 | if bar.ID() >= numBars-1 && i >= 42 { | |
| 144 | bar.Abort(true) | |
| 143 | if id := bar.ID(); id > 1 && i >= 42 { | |
| 144 | if id&1 == 1 { | |
| 145 | bar.Abort(true) | |
| 146 | } else { | |
| 147 | bar.Abort(false) | |
| 148 | } | |
| 145 | 149 | } |
| 146 | time.Sleep((time.Duration(rng.Intn(10)+1) * (10 * time.Millisecond)) / 2) | |
| 150 | time.Sleep((time.Duration(rng.Intn(10)+1) * (50 * time.Millisecond)) / 2) | |
| 147 | 151 | bar.Increment() |
| 148 | 152 | bar.DecoratorEwmaUpdate(time.Since(start)) |
| 149 | 153 | } |