Codebase list golang-github-vbauerster-mpb / 2d33ee5
drop sync bool param of BarQueueAfter Vladimir Bauer 3 years ago
5 changed file(s) with 8 addition(s) and 21 deletion(s). Raw diff Collapse all Expand all
4444 bar := p.AddBar(tasks[i].total,
4545 mpb.BarExtender(filler, true),
4646 mpb.BarFuncOptional(func() mpb.BarOption {
47 return mpb.BarQueueAfter(tasks[i-1].bar, false)
47 return mpb.BarQueueAfter(tasks[i-1].bar)
4848 }, i != 0),
4949 mpb.PrependDecorators(
5050 decor.Name("current:", decor.WCSyncWidthR),
2828 mpb.AppendDecorators(decor.Percentage(decor.WC{W: 5})),
2929 )
3030 queue[1] = p.AddBar(rand.Int63n(101)+100,
31 mpb.BarQueueAfter(queue[0], false), // this bar is queued
31 mpb.BarQueueAfter(queue[0]), // this bar is queued
3232 mpb.BarFillerClearOnComplete(),
3333 mpb.PrependDecorators(
3434 decor.Name(task, decor.WC{W: len(task) + 1, C: decor.DidentRight}),
5151 filler BarFiller
5252 extender extenderFunc
5353 refreshCh chan time.Time
54
55 wait struct {
56 bar *Bar // key for (*pState).queueBars
57 sync bool
58 }
54 waitBar *Bar // key for (*pState).queueBars
5955 }
6056
6157 type renderFrame struct {
399395
400396 func (b *Bar) serve(ctx context.Context, bs *bState) {
401397 defer b.container.bwg.Done()
402 if bs.wait.bar != nil && bs.wait.sync {
403 bs.wait.bar.Wait()
404 }
405398 for {
406399 select {
407400 case op := <-b.operateState:
5858 // BarQueueAfter puts this (being constructed) bar into the queue.
5959 // BarPriority will be inherited from the argument bar.
6060 // When argument bar completes or aborts queued bar replaces its place.
61 // If sync is true queued bar is suspended until argument bar completes
62 // or aborts.
63 func BarQueueAfter(bar *Bar, sync bool) BarOption {
64 if bar == nil {
65 return nil
66 }
67 return func(s *bState) {
68 s.wait.bar = bar
69 s.wait.sync = sync
61 func BarQueueAfter(bar *Bar) BarOption {
62 return func(s *bState) {
63 s.waitBar = bar
7064 }
7165 }
7266
134134 case p.operateState <- func(ps *pState) {
135135 bs := ps.makeBarState(total, filler, options...)
136136 bar := newBar(ps.ctx, p, bs)
137 if bs.wait.bar != nil {
138 ps.queueBars[bs.wait.bar] = bar
137 if bs.waitBar != nil {
138 ps.queueBars[bs.waitBar] = bar
139139 } else {
140140 ps.hm.push(bar, true)
141141 }