Update module github.com/vbauerster/mpb/v8 to v8.6.0

Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
renovate[bot]
2023-08-28 13:16:53 +00:00
committed by GitHub
parent 009ff3af69
commit fe11db1e81
9 changed files with 63 additions and 33 deletions

15
vendor/github.com/vbauerster/mpb/v8/CONTRIBUTING generated vendored Normal file
View File

@ -0,0 +1,15 @@
When contributing your first changes, please include an empty commit for
copyright waiver using the following message (replace 'John Doe' with
your name or nickname):
John Doe Copyright Waiver
I dedicate any and all copyright interest in this software to the
public domain. I make this dedication for the benefit of the public at
large and to the detriment of my heirs and successors. I intend this
dedication to be an overt act of relinquishment in perpetuity of all
present and future rights to this software under copyright law.
The command to create an empty commit from the command-line is:
git commit --allow-empty

View File

@ -338,7 +338,7 @@ func (b *Bar) DecoratorAverageAdjust(start time.Time) {
// 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.UpdateBarPriority(b, priority)
b.container.UpdateBarPriority(b, priority, false)
}
// Abort interrupts bar's running goroutine. Abort won't be engaged

View File

@ -0,0 +1,10 @@
package decor
// OnCompleteOrOnAbort wrap decorator.
// Displays provided message on complete or on abort event.
//
// `decorator` Decorator to wrap
// `message` message to display
func OnCompleteOrOnAbort(decorator Decorator, message string) Decorator {
return OnComplete(OnAbort(decorator, message), message)
}

View File

@ -1,8 +1,6 @@
package mpb
import (
"container/heap"
)
import "container/heap"
type heapManager chan heapRequest
@ -36,6 +34,7 @@ type pushData struct {
type fixData struct {
bar *Bar
priority int
lazy bool
}
func (m heapManager) run() {
@ -46,7 +45,6 @@ func (m heapManager) run() {
var sync bool
for req := range m {
next:
switch req.cmd {
case h_push:
data := req.data.(pushData)
@ -75,34 +73,35 @@ func (m heapManager) run() {
syncWidth(aMatrix, drop)
case h_iter:
data := req.data.(iterData)
drop_iter:
for _, b := range bHeap {
select {
case data.iter <- b:
case <-data.drop:
close(data.iter)
break next
break drop_iter
}
}
close(data.iter)
case h_drain:
data := req.data.(iterData)
drop_drain:
for bHeap.Len() != 0 {
select {
case data.iter <- heap.Pop(&bHeap).(*Bar):
case <-data.drop:
close(data.iter)
break next
break drop_drain
}
}
close(data.iter)
case h_fix:
data := req.data.(fixData)
bar, priority := data.bar, data.priority
if bar.index < 0 {
if data.bar.index < 0 {
break
}
bar.priority = priority
heap.Fix(&bHeap, bar.index)
data.bar.priority = data.priority
if !data.lazy {
heap.Fix(&bHeap, data.bar.index)
}
case h_state:
ch := req.data.(chan<- bool)
ch <- sync || l != bHeap.Len()
@ -137,8 +136,8 @@ func (m heapManager) drain(iter chan<- *Bar, drop <-chan struct{}) {
m <- heapRequest{cmd: h_drain, data: data}
}
func (m heapManager) fix(b *Bar, priority int) {
data := fixData{b, priority}
func (m heapManager) fix(b *Bar, priority int, lazy bool) {
data := fixData{b, priority, lazy}
m <- heapRequest{cmd: h_fix, data: data}
}

View File

@ -20,17 +20,18 @@ func (pq priorityQueue) Swap(i, j int) {
}
func (pq *priorityQueue) Push(x interface{}) {
s := *pq
n := len(*pq)
bar := x.(*Bar)
bar.index = len(s)
s = append(s, bar)
*pq = s
bar.index = n
*pq = append(*pq, bar)
}
func (pq *priorityQueue) Pop() interface{} {
s := *pq
*pq = s[0 : len(s)-1]
bar := s[len(s)-1]
old := *pq
n := len(old)
bar := old[n-1]
old[n-1] = nil // avoid memory leak
bar.index = -1 // for safety
*pq = old[:n-1]
return bar
}

View File

@ -201,10 +201,15 @@ func (p *Progress) traverseBars(cb func(b *Bar) bool) {
}
}
// UpdateBarPriority same as *Bar.SetPriority(int).
func (p *Progress) UpdateBarPriority(b *Bar, priority int) {
// UpdateBarPriority either immediately or lazy.
// With lazy flag order is updated after the next refresh cycle.
// If you don't care about laziness just use *Bar.SetPriority(int).
func (p *Progress) UpdateBarPriority(b *Bar, priority int, lazy bool) {
if b == nil {
return
}
select {
case p.operateState <- func(s *pState) { s.hm.fix(b, priority) }:
case p.operateState <- func(s *pState) { s.hm.fix(b, priority, lazy) }:
case <-p.done:
}
}