Codebase list golang-github-vbauerster-mpb / 1ea5126
declare rows inside pState.flush Vladimir Bauer 3 years ago
1 changed file(s) with 6 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
3636 hm heapManager
3737 dropS, dropD chan struct{}
3838 refreshCh chan time.Time
39 rows []io.Reader
4039
4140 // following are provided/overrided by user
4241 refreshRate time.Duration
7170 dropS: make(chan struct{}),
7271 dropD: make(chan struct{}),
7372 refreshCh: make(chan time.Time),
74 rows: make([]io.Reader, 32),
7573 refreshRate: defaultRefreshRate,
7674 popPriority: math.MinInt32,
7775 queueBars: make(map[*Bar]*Bar),
320318 defer wg.Wait() // waiting for all s.hm.push to complete
321319
322320 var popCount int
321 var rows []io.Reader
323322
324323 iter := make(chan *Bar)
325324 s.hm.drain(iter, s.dropD)
326 s.rows = s.rows[:0]
327325
328326 for b := range iter {
329327 frame := <-b.frameCh
334332 }
335333 var usedRows int
336334 for i := len(frame.rows) - 1; i >= 0; i-- {
337 if row := frame.rows[i]; len(s.rows) < height {
338 s.rows = append(s.rows, row)
335 if row := frame.rows[i]; len(rows) < height {
336 rows = append(rows, row)
339337 usedRows++
340338 } else {
341339 _, _ = io.Copy(io.Discard, row)
375373 }(b)
376374 }
377375
378 for i := len(s.rows) - 1; i >= 0; i-- {
379 _, err := cw.ReadFrom(s.rows[i])
376 for i := len(rows) - 1; i >= 0; i-- {
377 _, err := cw.ReadFrom(rows[i])
380378 if err != nil {
381379 return err
382380 }
383381 }
384382
385 return cw.Flush(len(s.rows) - popCount)
383 return cw.Flush(len(rows) - popCount)
386384 }
387385
388386 func (s *pState) makeBarState(total int64, filler BarFiller, options ...BarOption) *bState {