| 34 | 34 |
priority int // used by heap
|
| 35 | 35 |
index int // used by heap
|
| 36 | 36 |
|
| 37 | |
extendedLines int
|
| 38 | |
toShutdown bool
|
| 39 | |
dropOnComplete bool
|
| 40 | |
operateState chan func(*bState)
|
| 41 | |
frameCh chan io.Reader
|
| 42 | |
syncTableCh chan [][]chan int
|
| 43 | |
completed chan bool
|
|
37 |
extendedLines int
|
|
38 |
toShutdown bool
|
|
39 |
toDrop bool
|
|
40 |
operateState chan func(*bState)
|
|
41 |
frameCh chan io.Reader
|
|
42 |
syncTableCh chan [][]chan int
|
|
43 |
completed chan bool
|
| 44 | 44 |
|
| 45 | 45 |
// concel is called either by user or on complete event
|
| 46 | 46 |
cancel func()
|
|
| 99 | 99 |
logPrefix := fmt.Sprintf("%sbar#%02d ", container.dlogger.Prefix(), bs.id)
|
| 100 | 100 |
ctx, cancel := context.WithCancel(container.ctx)
|
| 101 | 101 |
bar := &Bar{
|
| 102 | |
container: container,
|
| 103 | |
priority: bs.priority,
|
| 104 | |
dropOnComplete: bs.dropOnComplete,
|
| 105 | |
operateState: make(chan func(*bState)),
|
| 106 | |
frameCh: make(chan io.Reader, 1),
|
| 107 | |
syncTableCh: make(chan [][]chan int),
|
| 108 | |
completed: make(chan bool, 1),
|
| 109 | |
done: make(chan struct{}),
|
| 110 | |
cancel: cancel,
|
| 111 | |
dlogger: log.New(bs.debugOut, logPrefix, log.Lshortfile),
|
|
102 |
container: container,
|
|
103 |
priority: bs.priority,
|
|
104 |
toDrop: bs.dropOnComplete,
|
|
105 |
operateState: make(chan func(*bState)),
|
|
106 |
frameCh: make(chan io.Reader, 1),
|
|
107 |
syncTableCh: make(chan [][]chan int),
|
|
108 |
completed: make(chan bool, 1),
|
|
109 |
done: make(chan struct{}),
|
|
110 |
cancel: cancel,
|
|
111 |
dlogger: log.New(bs.debugOut, logPrefix, log.Lshortfile),
|
| 112 | 112 |
}
|
| 113 | 113 |
|
| 114 | 114 |
go bar.serve(ctx, bs)
|
|
| 315 | 315 |
frame = io.MultiReader(frame, s.bufE)
|
| 316 | 316 |
}
|
| 317 | 317 |
|
|
318 |
b.toDrop = s.dropOnComplete
|
| 318 | 319 |
b.toShutdown = s.toComplete && !s.completeFlushed
|
| 319 | 320 |
s.completeFlushed = s.toComplete
|
| 320 | 321 |
|
|
| 408 | 409 |
}
|
| 409 | 410 |
}
|
| 410 | 411 |
|
|
412 |
func (b *Bar) dropOnComplete() {
|
|
413 |
select {
|
|
414 |
case b.operateState <- func(s *bState) { s.dropOnComplete = true }:
|
|
415 |
case <-b.done:
|
|
416 |
}
|
|
417 |
}
|
|
418 |
|
| 411 | 419 |
func newStatistics(s *bState) *decor.Statistics {
|
| 412 | 420 |
return &decor.Statistics{
|
| 413 | 421 |
ID: s.id,
|