refactoring: BarParkTo
Vladimir Bauer
7 years ago
| 47 | 47 |
job := "installing"
|
| 48 | 48 |
// preparing delayed bars
|
| 49 | 49 |
b := p.AddBar(rand.Int63n(101)+100,
|
| 50 | |
mpb.BarReplaceOnComplete(bars[i]),
|
|
50 |
mpb.BarParkTo(bars[i]),
|
| 51 | 51 |
mpb.BarClearOnComplete(),
|
| 52 | 52 |
mpb.PrependDecorators(
|
| 53 | 53 |
decor.Name(task, decor.WC{W: len(task) + 1, C: decor.DidentRight}),
|
| 60 | 60 |
}
|
| 61 | 61 |
}
|
| 62 | 62 |
|
| 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.
|
| 66 | 64 |
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 {
|
| 67 | 74 |
return func(s *bState) {
|
| 68 | 75 |
s.runningBar = runningBar
|
| 69 | 76 |
}
|