diff --git a/bar.go b/bar.go index e834a21..f47c4db 100644 --- a/bar.go +++ b/bar.go @@ -401,10 +401,13 @@ case op := <-b.operateState: op(bs) case <-b.ctx.Done(): + shutdownListeners := bs.shutdownListeners bs.aborted = !bs.completed() - bs.decoratorShutdownNotify(&b.container.bwg) b.bs = bs close(b.bsOk) + for _, d := range shutdownListeners { + d.OnShutdown() + } b.container.bwg.Done() return } @@ -588,17 +591,6 @@ } } -func (s bState) decoratorShutdownNotify(wg *sync.WaitGroup) { - wg.Add(len(s.shutdownListeners)) - for _, d := range s.shutdownListeners { - d := d - go func() { - d.OnShutdown() - wg.Done() - }() - } -} - func (s bState) newStatistics(tw int) decor.Statistics { return decor.Statistics{ AvailableWidth: tw,