From c31e10ec004074aabb9d2a40735fdd0911385c65 Mon Sep 17 00:00:00 2001 From: Vladimir Bauer Date: Sat, 17 Aug 2024 21:36:50 +0500 Subject: [PATCH] run shutdownListeners concurrently --- bar.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bar.go b/bar.go index 489b6cad..e3901be7 100644 --- a/bar.go +++ b/bar.go @@ -424,13 +424,17 @@ func (b *Bar) serve(bs *bState) { case op := <-b.operateState: op(bs) case <-b.ctx.Done(): - shutdownListeners := bs.shutdownListeners + for _, d := range bs.shutdownListeners { + b.container.bwg.Add(1) + d := d + go func() { + d.OnShutdown() + b.container.bwg.Done() + }() + } bs.aborted = !bs.completed() b.bs = bs close(b.bsOk) - for _, d := range shutdownListeners { - d.OnShutdown() - } b.container.bwg.Done() return }