refactoring: anon wait struct
Vladimir Bauer
3 years ago
| 60 | 60 |
rev bool
|
| 61 | 61 |
}
|
| 62 | 62 |
|
| 63 | |
afterBar *Bar // key for (*pState).queueBars
|
| 64 | |
sync bool
|
|
63 |
wait struct {
|
|
64 |
bar *Bar // key for (*pState).queueBars
|
|
65 |
sync bool
|
|
66 |
}
|
| 65 | 67 |
}
|
| 66 | 68 |
|
| 67 | 69 |
type renderFrame struct {
|
|
| 341 | 343 |
|
| 342 | 344 |
func (b *Bar) serve(ctx context.Context, bs *bState) {
|
| 343 | 345 |
defer b.container.bwg.Done()
|
| 344 | |
if bs.afterBar != nil && bs.sync {
|
| 345 | |
bs.afterBar.Wait()
|
|
346 |
if bs.wait.bar != nil && bs.wait.sync {
|
|
347 |
bs.wait.bar.Wait()
|
| 346 | 348 |
}
|
| 347 | 349 |
for {
|
| 348 | 350 |
select {
|
| 118 | 118 |
case p.operateState <- func(ps *pState) {
|
| 119 | 119 |
bs := ps.makeBarState(total, filler, options...)
|
| 120 | 120 |
bar := newBar(p, bs)
|
| 121 | |
if bs.afterBar != nil {
|
| 122 | |
ps.queueBars[bs.afterBar] = bar
|
|
121 |
if bs.wait.bar != nil {
|
|
122 |
ps.queueBars[bs.wait.bar] = bar
|
| 123 | 123 |
} else {
|
| 124 | 124 |
heap.Push(&ps.bHeap, bar)
|
| 125 | 125 |
ps.heapUpdated = true
|