Codebase list golang-github-vbauerster-mpb / 5a08c20
copy bs.priority to bar.priority Vladimir Bauer 4 years ago
3 changed file(s) with 6 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
1717 // Bar represents a progress bar.
1818 type Bar struct {
1919 index int // used by heap
20 priority int // used by heap
2021 hasEwmaDecorators bool
2122 frameCh chan *frame
2223 operateState chan func(*bState)
3233 // bState is actual bar's state.
3334 type bState struct {
3435 id int
35 priority int // used by heap
36 priority int
3637 reqWidth int
3738 total int64
3839 current int64
8687 }
8788
8889 bar := &Bar{
90 priority: bs.priority,
8991 frameCh: make(chan *frame, 1),
9092 operateState: operateState,
9193 done: done,
55 func (pq priorityQueue) Len() int { return len(pq) }
66
77 func (pq priorityQueue) Less(i, j int) bool {
8 return pq[i].bs.priority < pq[j].bs.priority
8 return pq[i].priority < pq[j].priority
99 }
1010
1111 func (pq priorityQueue) Swap(i, j int) {
165165 if b.index < 0 {
166166 return
167167 }
168 b.bs.priority = priority
168 b.priority = priority
169169 heap.Fix(&s.bHeap, b.index)
170170 }:
171171 case <-p.done:
330330 var toDrop bool
331331 if qb, ok := s.queueBars[b]; ok {
332332 delete(s.queueBars, b)
333 qb.bar.bs.priority = b.bs.priority
333 qb.bar.priority = b.priority
334334 heap.Push(&s.bHeap, qb.bar)
335335 go qb.serve()
336336 toDrop = true