Skip to content

Commit

Permalink
refactoring tryEarlyRefresh
Browse files Browse the repository at this point in the history
  • Loading branch information
vbauerster committed Dec 4, 2023
1 parent d078269 commit 2dcb25d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions bar.go
Original file line number Diff line number Diff line change
Expand Up @@ -460,12 +460,15 @@ func (b *Bar) triggerCompletion(s *bState) {
}

func (b *Bar) tryEarlyRefresh(renderReq chan<- time.Time) {
var anyOtherRunning bool
var otherRunning int
b.container.traverseBars(func(bar *Bar) bool {
anyOtherRunning = b != bar && bar.IsRunning()
return anyOtherRunning
if b != bar && bar.IsRunning() {
otherRunning++
return false // stop traverse
}
return true // continue traverse
})
if !anyOtherRunning {
if otherRunning == 0 {
for {
select {
case renderReq <- time.Now():
Expand Down
2 changes: 1 addition & 1 deletion progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (p *Progress) traverseBars(cb func(b *Bar) bool) {
select {
case p.operateState <- func(s *pState) { s.hm.iter(iter, drop) }:
for b := range iter {
if cb(b) {
if !cb(b) {
close(drop)
break
}
Expand Down

0 comments on commit 2dcb25d

Please sign in to comment.