aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/vbauerster/mpb/v7/progress.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-08-27 09:10:27 -0400
committerGitHub <noreply@github.com>2021-08-27 09:10:27 -0400
commit69cdf5d8035672e8bc7141cac0207e4b0f0e80cd (patch)
treebd2f9184eb3f7ca4aa7d3323b6fec350aae56209 /vendor/github.com/vbauerster/mpb/v7/progress.go
parent6f61ef87afe6695ca6cbd6e3b818ef619b6d54da (diff)
parentf5ce02b227f43feb7a02b09890facf198448621e (diff)
downloadpodman-69cdf5d8035672e8bc7141cac0207e4b0f0e80cd.tar.gz
podman-69cdf5d8035672e8bc7141cac0207e4b0f0e80cd.tar.bz2
podman-69cdf5d8035672e8bc7141cac0207e4b0f0e80cd.zip
Merge pull request #11330 from containers/dependabot/go_modules/github.com/containers/image/v5-5.16.0
Bump github.com/containers/image/v5 from 5.15.2 to 5.16.0
Diffstat (limited to 'vendor/github.com/vbauerster/mpb/v7/progress.go')
-rw-r--r--vendor/github.com/vbauerster/mpb/v7/progress.go46
1 files changed, 30 insertions, 16 deletions
diff --git a/vendor/github.com/vbauerster/mpb/v7/progress.go b/vendor/github.com/vbauerster/mpb/v7/progress.go
index b2017f3f0..c60c65694 100644
--- a/vendor/github.com/vbauerster/mpb/v7/progress.go
+++ b/vendor/github.com/vbauerster/mpb/v7/progress.go
@@ -19,7 +19,7 @@ import (
const (
// default RefreshRate
- prr = 120 * time.Millisecond
+ prr = 150 * time.Millisecond
)
// Progress represents a container that renders one or more progress
@@ -157,27 +157,40 @@ func (p *Progress) dropBar(b *Bar) {
}
}
-func (p *Progress) setBarPriority(b *Bar, priority int) {
+func (p *Progress) traverseBars(cb func(b *Bar) bool) {
+ done := make(chan struct{})
select {
case p.operateState <- func(s *pState) {
- if b.index < 0 {
- return
+ for i := 0; i < s.bHeap.Len(); i++ {
+ bar := s.bHeap[i]
+ if !cb(bar) {
+ break
+ }
}
- b.priority = priority
- heap.Fix(&s.bHeap, b.index)
+ close(done)
}:
+ <-done
case <-p.done:
}
}
// UpdateBarPriority same as *Bar.SetPriority(int).
func (p *Progress) UpdateBarPriority(b *Bar, priority int) {
- p.setBarPriority(b, priority)
+ select {
+ case p.operateState <- func(s *pState) {
+ if b.index < 0 {
+ return
+ }
+ b.priority = priority
+ heap.Fix(&s.bHeap, b.index)
+ }:
+ case <-p.done:
+ }
}
// BarCount returns bars count.
func (p *Progress) BarCount() int {
- result := make(chan int, 1)
+ result := make(chan int)
select {
case p.operateState <- func(s *pState) { result <- s.bHeap.Len() }:
return <-result
@@ -222,7 +235,7 @@ func (p *Progress) serve(s *pState, cw *cwriter.Writer) {
p.dlogger.Println(err)
}
case <-s.shutdownNotifier:
- if s.heapUpdated {
+ for s.heapUpdated {
if err := s.render(cw); err != nil {
p.dlogger.Println(err)
}
@@ -291,11 +304,12 @@ func (s *pState) render(cw *cwriter.Writer) error {
}
func (s *pState) flush(cw *cwriter.Writer) error {
- var lineCount int
- bm := make(map[*Bar]struct{}, s.bHeap.Len())
+ var totalLines int
+ bm := make(map[*Bar]int, s.bHeap.Len())
for s.bHeap.Len() > 0 {
b := heap.Pop(&s.bHeap).(*Bar)
- cw.ReadFrom(<-b.frameCh)
+ frame := <-b.frameCh
+ cw.ReadFrom(frame.reader)
if b.toShutdown {
if b.recoveredPanic != nil {
s.barShutdownQueue = append(s.barShutdownQueue, b)
@@ -308,8 +322,8 @@ func (s *pState) flush(cw *cwriter.Writer) error {
}()
}
}
- lineCount += b.extendedLines + 1
- bm[b] = struct{}{}
+ bm[b] = frame.lines
+ totalLines += frame.lines
}
for _, b := range s.barShutdownQueue {
@@ -320,7 +334,7 @@ func (s *pState) flush(cw *cwriter.Writer) error {
b.toDrop = true
}
if s.popCompleted && !b.noPop {
- lineCount -= b.extendedLines + 1
+ totalLines -= bm[b]
b.toDrop = true
}
if b.toDrop {
@@ -335,7 +349,7 @@ func (s *pState) flush(cw *cwriter.Writer) error {
heap.Push(&s.bHeap, b)
}
- return cw.Flush(lineCount)
+ return cw.Flush(totalLines)
}
func (s *pState) updateSyncMatrix() {