diff --git a/bar.go b/bar.go index 8c78758..b034b42 100644 --- a/bar.go +++ b/bar.go @@ -261,7 +261,7 @@ // priority, i.e. bar will be on top. If you don't need to set priority // dynamically, better use BarPriority option. func (b *Bar) SetPriority(priority int) { - b.container.setBarPriority(b, priority) + b.container.UpdateBarPriority(b, priority) } // Abort interrupts bar's running goroutine. Abort won't be engaged diff --git a/progress.go b/progress.go index 7ebbea2..c60c656 100644 --- a/progress.go +++ b/progress.go @@ -157,19 +157,6 @@ } } -func (p *Progress) setBarPriority(b *Bar, priority int) { - select { - case p.operateState <- func(s *pState) { - if b.index < 0 { - return - } - b.priority = priority - heap.Fix(&s.bHeap, b.index) - }: - case <-p.done: - } -} - func (p *Progress) traverseBars(cb func(b *Bar) bool) { done := make(chan struct{}) select { @@ -189,7 +176,16 @@ // 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.