Codebase list golang-github-vbauerster-mpb / 6047cab
Update remove example Vladimir Bauer 8 years ago
1 changed file(s) with 9 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
2323 for i := 0; i < numBars; i++ {
2424 var name string
2525 name = fmt.Sprintf("Bar#%d:", i)
26
27 var bOption mpb.BarOption
28 if i == 0 {
29 bOption = mpb.BarRemoveOnComplete()
30 }
31
2632 b := p.AddBar(int64(total), mpb.BarID(i),
2733 mpb.PrependDecorators(
2834 decor.StaticName(name, 0, decor.DwidthSync|decor.DidentRight),
3137 mpb.AppendDecorators(
3238 decor.Percentage(5, 0),
3339 ),
40 bOption,
3441 )
3542 go func() {
3643 defer wg.Done()
3744 max := 100 * time.Millisecond
3845 for i := 0; i < total; i++ {
39 if b.ID() == 1 && i == 42 {
40 p.RemoveBar(b)
46 if b.ID() == 2 && i == 42 {
47 p.Abort(b)
4148 return
4249 }
4350 time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10)
4451 b.Increment()
45 }
46 if b.ID() == 0 {
47 p.RemoveBar(b)
4852 }
4953 }()
5054 }