diff --git a/bar.go b/bar.go index dcee8c2..372df80 100644 --- a/bar.go +++ b/bar.go @@ -35,7 +35,6 @@ priority int index int - runningBar *Bar cacheState *bState operateState chan func(*bState) bFrameCh chan *bFrame @@ -77,8 +76,9 @@ bufE *bytes.Buffer panicMsg string - // following options are assigned to the *Bar - priority int + // priority overrides *Bar's priority, if set + priority int + // runningBar is a key for *pState.parkedBars runningBar *Bar } bFrame struct { @@ -106,7 +106,6 @@ bar := &Bar{ priority: bs.priority, - runningBar: bs.runningBar, operateState: make(chan func(*bState)), bFrameCh: make(chan *bFrame, 1), syncTableCh: make(chan [][]chan int), diff --git a/progress.go b/progress.go index 0c09098..4daa338 100644 --- a/progress.go +++ b/progress.go @@ -121,8 +121,6 @@ result := make(chan *Bar) select { case p.operateState <- func(ps *pState) { - logPrefix := fmt.Sprintf("%sbar#%02d ", p.dlogger.Prefix(), ps.idCounter) - dlogger := log.New(ps.debugOut, logPrefix, log.Lshortfile) bs := &bState{ total: total, filler: filler, @@ -135,12 +133,14 @@ opt(bs) } } + prefix := fmt.Sprintf("%sbar#%02d ", p.dlogger.Prefix(), bs.id) + dlogger := log.New(ps.debugOut, prefix, log.Lshortfile) bar := newBar(p.ctx, p.bwg, p.forceRefresh, bs, dlogger) - if bar.runningBar != nil { + if bs.runningBar != nil { if bar.priority == ps.idCounter { - bar.priority = bar.runningBar.priority - } - ps.parkedBars[bar.runningBar] = bar + bar.priority = bs.runningBar.priority + } + ps.parkedBars[bs.runningBar] = bar } else { heap.Push(ps.bHeap, bar) ps.heapUpdated = true