drop runningBar reference from Bar struct
Vladimir Bauer
7 years ago
| 34 | 34 |
priority int
|
| 35 | 35 |
index int
|
| 36 | 36 |
|
| 37 | |
runningBar *Bar
|
| 38 | 37 |
cacheState *bState
|
| 39 | 38 |
operateState chan func(*bState)
|
| 40 | 39 |
bFrameCh chan *bFrame
|
|
| 76 | 75 |
bufE *bytes.Buffer
|
| 77 | 76 |
panicMsg string
|
| 78 | 77 |
|
| 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
|
| 81 | 81 |
runningBar *Bar
|
| 82 | 82 |
}
|
| 83 | 83 |
bFrame struct {
|
|
| 105 | 105 |
|
| 106 | 106 |
bar := &Bar{
|
| 107 | 107 |
priority: bs.priority,
|
| 108 | |
runningBar: bs.runningBar,
|
| 109 | 108 |
operateState: make(chan func(*bState)),
|
| 110 | 109 |
bFrameCh: make(chan *bFrame, 1),
|
| 111 | 110 |
syncTableCh: make(chan [][]chan int),
|
| 120 | 120 |
result := make(chan *Bar)
|
| 121 | 121 |
select {
|
| 122 | 122 |
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)
|
| 125 | 123 |
bs := &bState{
|
| 126 | 124 |
total: total,
|
| 127 | 125 |
filler: filler,
|
|
| 134 | 132 |
opt(bs)
|
| 135 | 133 |
}
|
| 136 | 134 |
}
|
|
135 |
prefix := fmt.Sprintf("%sbar#%02d ", p.dlogger.Prefix(), bs.id)
|
|
136 |
dlogger := log.New(ps.debugOut, prefix, log.Lshortfile)
|
| 137 | 137 |
bar := newBar(p.ctx, p.bwg, p.forceRefresh, bs, dlogger)
|
| 138 | |
if bar.runningBar != nil {
|
|
138 |
if bs.runningBar != nil {
|
| 139 | 139 |
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
|
| 143 | 143 |
} else {
|
| 144 | 144 |
heap.Push(ps.bHeap, bar)
|
| 145 | 145 |
ps.heapUpdated = true
|