Codebase list golang-github-vbauerster-mpb / d8e281d
pass container.bwg to decoratorShutdownNotify Vladimir Bauer 1 year, 10 months ago
1 changed file(s) with 5 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
383383 }
384384
385385 func (b *Bar) serve(bs *bState) {
386 defer b.container.bwg.Done()
387386 for {
388387 select {
389388 case op := <-b.operateState:
390389 op(bs)
391390 case <-b.ctx.Done():
392391 bs.aborted = !bs.completed
393 bs.decoratorShutdownNotify()
392 bs.decoratorShutdownNotify(&b.container.bwg)
394393 b.bs = bs
395394 close(b.bsOk)
395 b.container.bwg.Done()
396396 return
397397 }
398398 }
581581 wg.Wait()
582582 }
583583
584 func (s bState) decoratorShutdownNotify() {
585 var wg sync.WaitGroup
584 func (s bState) decoratorShutdownNotify(wg *sync.WaitGroup) {
586585 for i := 0; i < len(s.shutdownListeners); i++ {
586 wg.Add(1)
587587 switch d := s.shutdownListeners[i]; i {
588588 case len(s.shutdownListeners) - 1:
589589 d.OnShutdown()
590 wg.Done()
590591 default:
591 wg.Add(1)
592592 go func() {
593593 d.OnShutdown()
594594 wg.Done()
595595 }()
596596 }
597597 }
598 wg.Wait()
599598 }
600599
601600 func newStatistics(tw int, s *bState) decor.Statistics {