diff --git a/bar.go b/bar.go index cc1c5d8..e4d4a49 100644 --- a/bar.go +++ b/bar.go @@ -18,6 +18,7 @@ // Bar represents a progress bar. type Bar struct { index int // used by heap + priority int // used by heap hasEwmaDecorators bool frameCh chan *frame operateState chan func(*bState) @@ -33,7 +34,7 @@ // bState is actual bar's state. type bState struct { id int - priority int // used by heap + priority int reqWidth int total int64 current int64 @@ -87,6 +88,7 @@ } bar := &Bar{ + priority: bs.priority, frameCh: make(chan *frame, 1), operateState: operateState, done: done, diff --git a/priority_queue.go b/priority_queue.go index 7f848bf..29d9bd5 100644 --- a/priority_queue.go +++ b/priority_queue.go @@ -6,7 +6,7 @@ func (pq priorityQueue) Len() int { return len(pq) } func (pq priorityQueue) Less(i, j int) bool { - return pq[i].bs.priority < pq[j].bs.priority + return pq[i].priority < pq[j].priority } func (pq priorityQueue) Swap(i, j int) { diff --git a/progress.go b/progress.go index 04a50e0..228ff73 100644 --- a/progress.go +++ b/progress.go @@ -166,7 +166,7 @@ if b.index < 0 { return } - b.bs.priority = priority + b.priority = priority heap.Fix(&s.bHeap, b.index) }: case <-p.done: @@ -331,7 +331,7 @@ var toDrop bool if qb, ok := s.queueBars[b]; ok { delete(s.queueBars, b) - qb.bar.bs.priority = b.bs.priority + qb.bar.priority = b.priority heap.Push(&s.bHeap, qb.bar) go qb.serve() toDrop = true