diff --git a/bar.go b/bar.go index 6d66443..b71e6b4 100644 --- a/bar.go +++ b/bar.go @@ -156,6 +156,7 @@ sync := make(chan struct{}) select { case b.operateState <- func(s *bState) { + defer close(sync) for _, decorators := range [][]decor.Decorator{ s.pDecorators, s.aDecorators, @@ -164,7 +165,6 @@ cb(extractBaseDecorator(d)) } } - close(sync) }: <-sync case <-b.done: diff --git a/progress.go b/progress.go index c409ad3..c9b5cc8 100644 --- a/progress.go +++ b/progress.go @@ -159,13 +159,13 @@ sync := make(chan struct{}) select { case p.operateState <- func(s *pState) { + defer close(sync) for i := 0; i < s.bHeap.Len(); i++ { bar := s.bHeap[i] if !cb(bar) { break } } - close(sync) }: <-sync case <-p.done: