Codebase list golang-github-vbauerster-mpb / 2eb7566
No critical to select in Completed, gain in performance Vladimir Bauer 8 years ago
1 changed file(s) with 2 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
269269 // Completed reports whether the bar is in completed state
270270 func (b *Bar) Completed() bool {
271271 result := make(chan bool)
272 select {
273 case b.operateState <- func(s *bState) { result <- s.toComplete }:
274 return <-result
275 case <-b.done:
276 return b.cacheState.toComplete
277 }
272 b.operateState <- func(s *bState) { result <- s.toComplete }
273 return <-result
278274 }
279275
280276 func (b *Bar) serve(wg *sync.WaitGroup, s *bState, cancel <-chan struct{}) {