Codebase list golang-github-vbauerster-mpb / 7d4a8a0
make Abort method more atomic Vladimir Bauer 4 years ago
1 changed file(s) with 9 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
266266 // if bar is already in complete state. If drop is true bar will be
267267 // removed as well.
268268 func (b *Bar) Abort(drop bool) {
269 if b.Completed() {
270 return
271 }
272 select {
273 case <-b.done:
274 default:
269 select {
270 case b.operateState <- func(s *bState) {
271 if s.completed == true {
272 return
273 }
275274 if drop {
276275 b.container.dropBar(b)
277 } else if b.container.BarCount() == 1 {
276 } else {
278277 b.container.refreshCh <- time.Now()
279278 }
280279 b.cancel()
280 }:
281 <-b.done
282 case <-b.done:
281283 }
282284 }
283285