Codebase list golang-github-vbauerster-mpb / b9f78f8
drop runningBar reference from Bar struct Vladimir Bauer 7 years ago
2 changed file(s) with 9 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
3434 priority int
3535 index int
3636
37 runningBar *Bar
3837 cacheState *bState
3938 operateState chan func(*bState)
4039 bFrameCh chan *bFrame
7675 bufE *bytes.Buffer
7776 panicMsg string
7877
79 // following options are assigned to the *Bar
80 priority int
78 // priority overrides *Bar's priority, if set
79 priority int
80 // runningBar is a key for *pState.parkedBars
8181 runningBar *Bar
8282 }
8383 bFrame struct {
105105
106106 bar := &Bar{
107107 priority: bs.priority,
108 runningBar: bs.runningBar,
109108 operateState: make(chan func(*bState)),
110109 bFrameCh: make(chan *bFrame, 1),
111110 syncTableCh: make(chan [][]chan int),
120120 result := make(chan *Bar)
121121 select {
122122 case p.operateState <- func(ps *pState) {
123 logPrefix := fmt.Sprintf("%sbar#%02d ", p.dlogger.Prefix(), ps.idCounter)
124 dlogger := log.New(ps.debugOut, logPrefix, log.Lshortfile)
125123 bs := &bState{
126124 total: total,
127125 filler: filler,
134132 opt(bs)
135133 }
136134 }
135 prefix := fmt.Sprintf("%sbar#%02d ", p.dlogger.Prefix(), bs.id)
136 dlogger := log.New(ps.debugOut, prefix, log.Lshortfile)
137137 bar := newBar(p.ctx, p.bwg, p.forceRefresh, bs, dlogger)
138 if bar.runningBar != nil {
138 if bs.runningBar != nil {
139139 if bar.priority == ps.idCounter {
140 bar.priority = bar.runningBar.priority
141 }
142 ps.parkedBars[bar.runningBar] = bar
140 bar.priority = bs.runningBar.priority
141 }
142 ps.parkedBars[bs.runningBar] = bar
143143 } else {
144144 heap.Push(ps.bHeap, bar)
145145 ps.heapUpdated = true