Codebase list golang-github-vbauerster-mpb / 9873d12
introduce bool value decor.Statistics.Aborted address issue #103 Vladimir Bauer 4 years ago
3 changed file(s) with 14 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
2525 decor.Name(name),
2626 decor.EwmaETA(decor.ET_STYLE_GO, 60, decor.WCSyncSpace),
2727 ),
28 mpb.AppendDecorators(decor.Percentage(decor.WCSyncSpace)),
28 mpb.AppendDecorators(
29 decor.Any(func(s decor.Statistics) string {
30 return fmt.Sprintf("completed: %v", s.Completed)
31 }, decor.WCSyncSpaceR),
32 decor.Any(func(s decor.Statistics) string {
33 return fmt.Sprintf("aborted: %v", s.Aborted)
34 }, decor.WCSyncSpaceR),
35 decor.OnComplete(decor.Percentage(decor.WCSyncSpace), "done"),
36 ),
2937 )
3038 go func() {
3139 defer wg.Done()
5454 trimSpace bool
5555 completed bool
5656 completeFlushed bool
57 aborted bool
5758 triggerComplete bool
5859 dropOnComplete bool
5960 noPop bool
281282 close(done)
282283 return
283284 }
285 s.aborted = true
286 b.cancel()
284287 // container must be run during lifetime of this inner goroutine
285288 // we control this by done channel declared above
286289 go func() {
301304 }
302305 close(done) // release hold of Abort
303306 }()
304 b.cancel()
305307 }:
306308 // guarantee: container is alive during lifetime of this hold
307309 <-done
531533 Current: s.current,
532534 Refill: s.refill,
533535 Completed: s.completeFlushed,
536 Aborted: s.aborted,
534537 }
535538 }
536539
5252 Current int64
5353 Refill int64
5454 Completed bool
55 Aborted bool
5556 }
5657
5758 // Decorator interface.