Codebase list golang-github-vbauerster-mpb / 6c2fd38
disableAutoRefresh Vladimir Bauer 3 years ago
2 changed file(s) with 24 addition(s) and 25 deletion(s). Raw diff Collapse all Expand all
4141 func WithManualRefresh(ch <-chan interface{}) ContainerOption {
4242 return func(s *pState) {
4343 s.externalRefresh = ch
44 s.disableAutoRefresh = true
4445 }
4546 }
4647
2929 operateState chan func(*pState)
3030 interceptIo chan func(io.Writer)
3131 done chan struct{}
32 refreshCh chan time.Time
3332 once sync.Once
3433 cancel func()
3534 }
4645 pool []*Bar
4746
4847 // following are provided/overrided by user
49 idCount int
50 reqWidth int
51 popPriority int
52 popCompleted bool
53 outputDiscarded bool
54 rr time.Duration
55 uwg *sync.WaitGroup
56 externalRefresh <-chan interface{}
57 renderDelay <-chan struct{}
58 shutdownNotifier chan struct{}
59 queueBars map[*Bar]*Bar
60 output io.Writer
61 debugOut io.Writer
48 idCount int
49 reqWidth int
50 popPriority int
51 popCompleted bool
52 outputDiscarded bool
53 disableAutoRefresh bool
54 rr time.Duration
55 uwg *sync.WaitGroup
56 externalRefresh <-chan interface{}
57 renderDelay <-chan struct{}
58 shutdownNotifier chan struct{}
59 queueBars map[*Bar]*Bar
60 output io.Writer
61 debugOut io.Writer
6262 }
6363
6464 // New creates new Progress container instance. It's not possible to
374374 s.shutdownNotifier = make(chan struct{})
375375 }
376376 go func() {
377 if s.renderDelay != nil {
378 <-s.renderDelay
379 }
380 var internalRefresh <-chan time.Time
381 if !s.outputDiscarded {
382 if s.externalRefresh == nil {
377 var autoRefresh <-chan time.Time
378 if !s.disableAutoRefresh {
379 if !s.outputDiscarded {
380 if s.renderDelay != nil {
381 <-s.renderDelay
382 }
383383 ticker := time.NewTicker(s.rr)
384384 defer ticker.Stop()
385 internalRefresh = ticker.C
386 }
387 } else {
388 s.externalRefresh = nil
385 autoRefresh = ticker.C
386 }
389387 }
390388 for {
391389 select {
392 case t := <-internalRefresh:
390 case t := <-autoRefresh:
393391 ch <- t
394392 case x := <-s.externalRefresh:
395393 if t, ok := x.(time.Time); ok {