Codebase list golang-github-vbauerster-mpb / abc3adb
refactoring newTicker takes what it really needs Vladimir Bauer 3 years ago
1 changed file(s) with 4 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
216216 <-p.shutdown
217217 }
218218
219 func (p *Progress) newTicker(s *pState, isTerminal bool) chan time.Time {
219 func (s *pState) newTicker(ctx context.Context, isTerminal bool, done chan struct{}) chan time.Time {
220220 ch := make(chan time.Time, 1)
221221 go func() {
222222 var autoRefresh <-chan time.Time
238238 } else {
239239 ch <- time.Now()
240240 }
241 case <-p.ctx.Done():
242 close(p.done)
241 case <-ctx.Done():
242 close(done)
243243 return
244244 }
245245 }
250250 func (p *Progress) serve(s *pState, cw *cwriter.Writer) {
251251 var err error
252252 render := func() error { return s.render(cw) }
253 tickerC := p.newTicker(s, cw.IsTerminal())
253 tickerC := s.newTicker(p.ctx, cw.IsTerminal(), p.done)
254254
255255 for {
256256 select {