Codebase list golang-github-vbauerster-mpb / 2640a67
BarPriority option Vladimir Bauer 8 years ago
3 changed file(s) with 16 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
5858 trimLeftSpace bool
5959 trimRightSpace bool
6060 toComplete bool
61 removeOnComplete bool
6261 dynamic bool
6362 startTime time.Time
6463 timeElapsed time.Duration
6968 refill *refill
7069 bufP, bufB, bufA *bytes.Buffer
7170 panicMsg string
71
72 // following options are assigned to the *Bar
73 priority int
74 removeOnComplete bool
7275 }
7376 refill struct {
7477 char rune
8891
8992 s := &bState{
9093 id: id,
94 priority: id,
9195 total: total,
9296 etaAlpha: etaAlpha,
9397 }
103107 s.bufA = bytes.NewBuffer(make([]byte, 0, s.width))
104108
105109 b := &Bar{
106 priority: id,
110 priority: s.priority,
107111 removeOnComplete: s.removeOnComplete,
108112 operateState: make(chan func(*bState)),
109113 done: make(chan struct{}),
8181 }
8282 }
8383
84 // BarPriority sets bar's priority.
85 // Zero is highest priority, i.e. bar will be on top.
86 func BarPriority(priority int) BarOption {
87 return func(s *bState) {
88 s.priority = priority
89 }
90 }
91
8492 func barWidth(w int) BarOption {
8593 return func(s *bState) {
8694 s.width = w
11
22 import "container/heap"
33
4 // A priorityQueue implements heap.Interface and holds Items.
4 // A priorityQueue implements heap.Interface
55 type priorityQueue []*Bar
66
77 func (pq priorityQueue) Len() int { return len(pq) }
3232 return bar
3333 }
3434
35 // update modifies the priority of an Bar in the queue.
35 // update modifies the priority of a Bar in the queue.
3636 func (pq *priorityQueue) update(bar *Bar, priority int) {
3737 bar.priority = priority
3838 heap.Fix(pq, bar.index)