Codebase list golang-github-vbauerster-mpb / 08eaef3
move newTicker close to call Vladimir Bauer 6 years ago
1 changed file(s) with 27 addition(s) and 27 deletion(s). Raw diff Collapse all Expand all
222222 return
223223 }
224224 }
225 }
226
227 func (s *pState) newTicker(done <-chan struct{}) chan time.Time {
228 ch := make(chan time.Time)
229 if s.shutdownNotifier == nil {
230 s.shutdownNotifier = make(chan struct{})
231 }
232 go func() {
233 if s.renderDelay != nil {
234 <-s.renderDelay
235 }
236 if s.refreshSrc == nil {
237 ticker := time.NewTicker(s.rr)
238 defer ticker.Stop()
239 s.refreshSrc = ticker.C
240 }
241 for {
242 select {
243 case tick := <-s.refreshSrc:
244 ch <- tick
245 case <-done:
246 close(s.shutdownNotifier)
247 return
248 }
249 }
250 }()
251 return ch
225252 }
226253
227254 func (s *pState) render(cw *cwriter.Writer) error {
301328 return cw.Flush(lineCount)
302329 }
303330
304 func (s *pState) newTicker(done <-chan struct{}) chan time.Time {
305 ch := make(chan time.Time)
306 if s.shutdownNotifier == nil {
307 s.shutdownNotifier = make(chan struct{})
308 }
309 go func() {
310 if s.renderDelay != nil {
311 <-s.renderDelay
312 }
313 if s.refreshSrc == nil {
314 ticker := time.NewTicker(s.rr)
315 defer ticker.Stop()
316 s.refreshSrc = ticker.C
317 }
318 for {
319 select {
320 case tick := <-s.refreshSrc:
321 ch <- tick
322 case <-done:
323 close(s.shutdownNotifier)
324 return
325 }
326 }
327 }()
328 return ch
329 }
330
331331 func (s *pState) updateSyncMatrix() {
332332 s.pMatrix = make(map[int][]chan int)
333333 s.aMatrix = make(map[int][]chan int)