Codebase list golang-github-vbauerster-mpb / 19262a1
refactoring: anon wait struct Vladimir Bauer 3 years ago
3 changed file(s) with 10 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
6060 rev bool
6161 }
6262
63 afterBar *Bar // key for (*pState).queueBars
64 sync bool
63 wait struct {
64 bar *Bar // key for (*pState).queueBars
65 sync bool
66 }
6567 }
6668
6769 type renderFrame struct {
341343
342344 func (b *Bar) serve(ctx context.Context, bs *bState) {
343345 defer b.container.bwg.Done()
344 if bs.afterBar != nil && bs.sync {
345 bs.afterBar.Wait()
346 if bs.wait.bar != nil && bs.wait.sync {
347 bs.wait.bar.Wait()
346348 }
347349 for {
348350 select {
6868 return nil
6969 }
7070 return func(s *bState) {
71 s.afterBar = bar
72 s.sync = sync
71 s.wait.bar = bar
72 s.wait.sync = sync
7373 }
7474 }
7575
118118 case p.operateState <- func(ps *pState) {
119119 bs := ps.makeBarState(total, filler, options...)
120120 bar := newBar(p, bs)
121 if bs.afterBar != nil {
122 ps.queueBars[bs.afterBar] = bar
121 if bs.wait.bar != nil {
122 ps.queueBars[bs.wait.bar] = bar
123123 } else {
124124 heap.Push(&ps.bHeap, bar)
125125 ps.heapUpdated = true