Codebase list golang-github-vbauerster-mpb / de67b4e
make result chan inside Completed there is no win in keeping it on bar instance. Vladimir Bauer 4 years ago
1 changed file(s) with 4 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
2626 operateState chan func(*bState)
2727 frameCh chan *frame
2828 syncTableCh chan [][]chan int
29 completed chan bool
3029
3130 // cancel is called either by user or on complete event
3231 cancel func()
9291 operateState: make(chan func(*bState)),
9392 frameCh: make(chan *frame, 1),
9493 syncTableCh: make(chan [][]chan int, 1),
95 completed: make(chan bool, 1),
9694 done: make(chan struct{}),
9795 cancel: cancel,
9896 dlogger: log.New(bs.debugOut, logPrefix, log.Lshortfile),
286284
287285 // Completed reports whether the bar is in completed state.
288286 func (b *Bar) Completed() bool {
289 select {
290 case b.operateState <- func(s *bState) { b.completed <- s.completed }:
291 return <-b.completed
287 result := make(chan bool)
288 select {
289 case b.operateState <- func(s *bState) { result <- s.completed }:
290 return <-result
292291 case <-b.done:
293292 return true
294293 }