godocs
Vladimir Bauer
5 years ago
| 14 | 14 |
"github.com/vbauerster/mpb/v6/decor"
|
| 15 | 15 |
)
|
| 16 | 16 |
|
| 17 | |
// Bar represents a progress Bar.
|
|
17 |
// Bar represents a progress bar.
|
| 18 | 18 |
type Bar struct {
|
| 19 | 19 |
priority int // used by heap
|
| 20 | 20 |
index int // used by heap
|
|
| 43 | 43 |
|
| 44 | 44 |
type extenderFunc func(in io.Reader, reqWidth int, st decor.Statistics) (out io.Reader, lines int)
|
| 45 | 45 |
|
|
46 |
// bState is actual bar state. It gets passed to *Bar.serve(...) monitor
|
|
47 |
// goroutine.
|
| 46 | 48 |
type bState struct {
|
| 47 | 49 |
id int
|
| 48 | 50 |
priority int
|
| 21 | 21 |
prr = 120 * time.Millisecond
|
| 22 | 22 |
)
|
| 23 | 23 |
|
| 24 | |
// Progress represents the container that renders Progress bars
|
|
24 |
// Progress represents a container that renders one or more progress
|
|
25 |
// bars.
|
| 25 | 26 |
type Progress struct {
|
| 26 | 27 |
ctx context.Context
|
| 27 | 28 |
uwg *sync.WaitGroup
|
|
| 34 | 35 |
dlogger *log.Logger
|
| 35 | 36 |
}
|
| 36 | 37 |
|
|
38 |
// pState holds bars in its priorityQueue. It gets passed to
|
|
39 |
// *Progress.serve(...) monitor goroutine.
|
| 37 | 40 |
type pState struct {
|
| 38 | 41 |
bHeap priorityQueue
|
| 39 | 42 |
heapUpdated bool
|
|
| 171 | 174 |
p.setBarPriority(b, priority)
|
| 172 | 175 |
}
|
| 173 | 176 |
|
| 174 | |
// BarCount returns bars count
|
|
177 |
// BarCount returns bars count.
|
| 175 | 178 |
func (p *Progress) BarCount() int {
|
| 176 | 179 |
result := make(chan int, 1)
|
| 177 | 180 |
select {
|