Codebase list golang-github-vbauerster-mpb / b115126
IsRunning: no need to occupy b.operateState Vladimir Bauer 1 year, 10 months ago
1 changed file(s) with 5 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
370370 }
371371 }
372372
373 // IsRunning reports whether the bar is running, i.e. not yet completed
374 // and not yet aborted.
373 // IsRunning reports whether the bar is in running state.
375374 func (b *Bar) IsRunning() bool {
376 result := make(chan bool)
377 select {
378 case b.operateState <- func(s *bState) { result <- !s.completed && !s.aborted }:
379 return <-result
380 case <-b.done:
375 select {
376 case <-b.ctx.Done():
381377 return false
378 default:
379 return true
382380 }
383381 }
384382