diff --git a/_examples/sortBars/main.go b/_examples/sortBars/main.go index 9a8afc5..05e963a 100644 --- a/_examples/sortBars/main.go +++ b/_examples/sortBars/main.go @@ -41,7 +41,7 @@ time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10) if i&1 == 1 { priority := total - int(b.Current()) - p.UpdateBarPriority(b, priority) + b.SetPriority(priority) } // ewma based decorators require work duration measurement b.IncrBy(1, time.Since(start)) diff --git a/bar.go b/bar.go index d702bd8..2bf2b59 100644 --- a/bar.go +++ b/bar.go @@ -228,14 +228,14 @@ } } -// SetOrder changes bar's order among multiple bars. Zero is highest -// priority, i.e. bar will be on top. If you don't need to set order +// SetPriority changes bar's order among multiple bars. Zero is highest +// priority, i.e. bar will be on top. If you don't need to set priority // dynamically, better use BarPriority option. -func (b *Bar) SetOrder(order int) { +func (b *Bar) SetPriority(priority int) { select { case <-b.done: default: - b.container.setBarOrder(b, order) + b.container.setBarPriority(b, priority) } } diff --git a/progress.go b/progress.go index 19869df..fbd5f2d 100644 --- a/progress.go +++ b/progress.go @@ -166,12 +166,12 @@ // UpdateBarPriority is deprecated. Please use *Bar.SetOrder. func (p *Progress) UpdateBarPriority(b *Bar, priority int) { - p.setBarOrder(b, priority) -} - -func (p *Progress) setBarOrder(b *Bar, order int) { + p.setBarPriority(b, priority) +} + +func (p *Progress) setBarPriority(b *Bar, priority int) { select { - case p.operateState <- func(s *pState) { s.bHeap.update(b, order) }: + case p.operateState <- func(s *pState) { s.bHeap.update(b, priority) }: case <-p.done: } }