Codebase list golang-github-vbauerster-mpb / d5d1c0f
add sync param to BarQueueAfter option Vladimir Bauer 4 years ago
2 changed file(s) with 10 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
5757 extender extenderFunc
5858 debugOut io.Writer
5959
60 // afterBar is a key for (*pState).queueBars
61 afterBar *Bar
60 afterBar *Bar // key for (*pState).queueBars
61 sync bool
6262 }
6363
6464 type frame struct {
299299
300300 func (b *Bar) serve(ctx context.Context, bs *bState) {
301301 defer b.container.bwg.Done()
302 if bs.afterBar != nil && bs.sync {
303 <-bs.afterBar.done
304 }
302305 for {
303306 select {
304307 case op := <-b.operateState:
5959 }
6060
6161 // BarQueueAfter puts this (being constructed) bar into the queue.
62 // Queued bar will run after argument bar completes, replacing its
63 // place. While bar is queued all of its methods are blocked.
64 func BarQueueAfter(bar *Bar) BarOption {
62 // When argument bar completes or aborts queued bar replaces its place.
63 // If sync is true queued bar is suspended until argument bar completes
64 // or aborts.
65 func BarQueueAfter(bar *Bar, sync bool) BarOption {
6566 if bar == nil {
6667 return nil
6768 }
6869 return func(s *bState) {
6970 s.afterBar = bar
71 s.sync = sync
7072 }
7173 }
7274