Codebase list golang-github-vbauerster-mpb / d20d40e
rename externalRefresh to manualRefresh Vladimir Bauer 3 years ago
3 changed file(s) with 24 addition(s) and 24 deletion(s). Raw diff Collapse all Expand all
5151 filler BarFiller
5252 middleware func(BarFiller) BarFiller
5353 extender extenderFunc
54 refreshCh chan interface{}
54 manualRefresh chan interface{}
5555
5656 wait struct {
5757 bar *Bar // key for (*pState).queueBars
184184 if s.current >= s.total {
185185 s.current = s.total
186186 s.completed = true
187 go b.forceRefresh(s.refreshCh)
187 go b.forceRefresh(s.manualRefresh)
188188 } else {
189189 s.triggerComplete = true
190190 }
212212 if triggerCompleteNow {
213213 s.current = s.total
214214 s.completed = true
215 go b.forceRefresh(s.refreshCh)
215 go b.forceRefresh(s.manualRefresh)
216216 }
217217 }:
218218 case <-b.done:
229229 if s.triggerComplete && s.current >= s.total {
230230 s.current = s.total
231231 s.completed = true
232 go b.forceRefresh(s.refreshCh)
232 go b.forceRefresh(s.manualRefresh)
233233 }
234234 }:
235235 case <-b.done:
258258 if s.triggerComplete && s.current >= s.total {
259259 s.current = s.total
260260 s.completed = true
261 go b.forceRefresh(s.refreshCh)
261 go b.forceRefresh(s.manualRefresh)
262262 }
263263 }:
264264 case <-b.done:
318318 }
319319 s.aborted = true
320320 s.dropOnComplete = drop
321 go b.forceRefresh(s.refreshCh)
321 go b.forceRefresh(s.manualRefresh)
322322 }:
323323 case <-b.done:
324324 }
4040 // Refresh will occur upon receive value from provided ch.
4141 func WithManualRefresh(ch chan interface{}) ContainerOption {
4242 return func(s *pState) {
43 s.externalRefresh = ch
43 s.manualRefresh = ch
4444 s.disableAutoRefresh = true
4545 }
4646 }
5252 popCompleted bool
5353 outputDiscarded bool
5454 disableAutoRefresh bool
55 externalRefresh chan interface{}
55 manualRefresh chan interface{}
5656 renderDelay <-chan struct{}
5757 shutdownNotifier chan struct{}
5858 queueBars map[*Bar]*Bar
7373 func NewWithContext(ctx context.Context, options ...ContainerOption) *Progress {
7474 ctx, cancel := context.WithCancel(ctx)
7575 s := &pState{
76 rr: prr,
77 bHeap: priorityQueue{},
78 rows: make([]io.Reader, 0, 64),
79 pool: make([]*Bar, 0, 64),
80 externalRefresh: make(chan interface{}),
81 queueBars: make(map[*Bar]*Bar),
82 popPriority: math.MinInt32,
83 output: os.Stdout,
84 debugOut: io.Discard,
76 rr: prr,
77 bHeap: priorityQueue{},
78 rows: make([]io.Reader, 0, 64),
79 pool: make([]*Bar, 0, 64),
80 manualRefresh: make(chan interface{}),
81 queueBars: make(map[*Bar]*Bar),
82 popPriority: math.MinInt32,
83 output: os.Stdout,
84 debugOut: io.Discard,
8585 }
8686
8787 for _, opt := range options {
391391 select {
392392 case t := <-autoRefresh:
393393 ch <- t
394 case x := <-s.externalRefresh:
394 case x := <-s.manualRefresh:
395395 if t, ok := x.(time.Time); ok {
396396 ch <- t
397397 } else {
426426
427427 func (s *pState) makeBarState(total int64, filler BarFiller, options ...BarOption) *bState {
428428 bs := &bState{
429 id: s.idCount,
430 priority: s.idCount,
431 reqWidth: s.reqWidth,
432 total: total,
433 filler: filler,
434 refreshCh: s.externalRefresh,
429 id: s.idCount,
430 priority: s.idCount,
431 reqWidth: s.reqWidth,
432 total: total,
433 filler: filler,
434 manualRefresh: s.manualRefresh,
435435 }
436436
437437 if total > 0 {