diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-09-13 11:09:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-13 11:09:26 +0200 |
commit | 1b3e8639f3a9041dcbc26b22b9c244a679075734 (patch) | |
tree | 3cbe2c5fa5c6acd0918a9d323399dac9ed868278 /vendor/github.com/vbauerster/mpb/v7/progress.go | |
parent | 0f39129551bb59a2274780d35feb57369155caba (diff) | |
parent | 9457549fff7aee6246bf2f51659050c74586aed5 (diff) | |
download | podman-1b3e8639f3a9041dcbc26b22b9c244a679075734.tar.gz podman-1b3e8639f3a9041dcbc26b22b9c244a679075734.tar.bz2 podman-1b3e8639f3a9041dcbc26b22b9c244a679075734.zip |
Merge pull request #15750 from containers/dependabot/go_modules/github.com/vbauerster/mpb/v7-7.5.3
build(deps): bump github.com/vbauerster/mpb/v7 from 7.5.2 to 7.5.3
Diffstat (limited to 'vendor/github.com/vbauerster/mpb/v7/progress.go')
-rw-r--r-- | vendor/github.com/vbauerster/mpb/v7/progress.go | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/vendor/github.com/vbauerster/mpb/v7/progress.go b/vendor/github.com/vbauerster/mpb/v7/progress.go index ea5a0c15e..1dda06e5f 100644 --- a/vendor/github.com/vbauerster/mpb/v7/progress.go +++ b/vendor/github.com/vbauerster/mpb/v7/progress.go @@ -254,19 +254,25 @@ func (s *pState) render(cw *cwriter.Writer) error { } func (s *pState) flush(cw *cwriter.Writer, height int) error { + var wg sync.WaitGroup var popCount int rows := make([]io.Reader, 0, height) pool := make([]*Bar, 0, s.bHeap.Len()) for s.bHeap.Len() > 0 { - var frameRowsUsed int + var usedRows int b := heap.Pop(&s.bHeap).(*Bar) frame := <-b.frameCh for i := len(frame.rows) - 1; i >= 0; i-- { - if len(rows) == height { - break + if row := frame.rows[i]; len(rows) < height { + rows = append(rows, row) + usedRows++ + } else { + wg.Add(1) + go func() { + _, _ = io.Copy(io.Discard, row) + wg.Done() + }() } - rows = append(rows, frame.rows[i]) - frameRowsUsed++ } if frame.shutdown != 0 { b.Wait() // waiting for b.done, so it's safe to read b.bs @@ -278,7 +284,7 @@ func (s *pState) flush(cw *cwriter.Writer, height int) error { drop = true } else if s.popCompleted && !b.bs.noPop { if frame.shutdown > 1 { - popCount += frameRowsUsed + popCount += usedRows drop = true } else { s.popPriority++ @@ -300,10 +306,12 @@ func (s *pState) flush(cw *cwriter.Writer, height int) error { for i := len(rows) - 1; i >= 0; i-- { _, err := cw.ReadFrom(rows[i]) if err != nil { + wg.Wait() return err } } + wg.Wait() return cw.Flush(len(rows) - popCount) } |