Codebase list golang-github-vbauerster-mpb / 63e2b00
refactoring: BarParkTo Vladimir Bauer 7 years ago
2 changed file(s) with 11 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
4747 job := "installing"
4848 // preparing delayed bars
4949 b := p.AddBar(rand.Int63n(101)+100,
50 mpb.BarReplaceOnComplete(bars[i]),
50 mpb.BarParkTo(bars[i]),
5151 mpb.BarClearOnComplete(),
5252 mpb.PrependDecorators(
5353 decor.Name(task, decor.WC{W: len(task) + 1, C: decor.DidentRight}),
6060 }
6161 }
6262
63 // BarReplaceOnComplete is indicator for delayed bar start, after the
64 // `runningBar` is complete. To achieve bar replacement effect,
65 // `runningBar` should has its `BarRemoveOnComplete` option set.
63 // BarReplaceOnComplete is deprecated. Refer to BarParkTo option.
6664 func BarReplaceOnComplete(runningBar *Bar) BarOption {
65 return BarParkTo(runningBar)
66 }
67
68 // BarParkTo parks constructed bar into the runningBar. In other words,
69 // constructed bar will start only after runningBar has been completed.
70 // Parked bar will replace runningBar if BarRemoveOnComplete option
71 // is set on the runningBar. Parked bar inherits priority of the
72 // runningBar, if no BarPriority option is set.
73 func BarParkTo(runningBar *Bar) BarOption {
6774 return func(s *bState) {
6875 s.runningBar = runningBar
6976 }