diff --git a/_examples/remove/main.go b/_examples/remove/main.go index b53c1df..b191b4c 100644 --- a/_examples/remove/main.go +++ b/_examples/remove/main.go @@ -26,7 +26,15 @@ decor.Name(name), decor.EwmaETA(decor.ET_STYLE_GO, 60, decor.WCSyncSpace), ), - mpb.AppendDecorators(decor.Percentage(decor.WCSyncSpace)), + mpb.AppendDecorators( + decor.Any(func(s decor.Statistics) string { + return fmt.Sprintf("completed: %v", s.Completed) + }, decor.WCSyncSpaceR), + decor.Any(func(s decor.Statistics) string { + return fmt.Sprintf("aborted: %v", s.Aborted) + }, decor.WCSyncSpaceR), + decor.OnComplete(decor.Percentage(decor.WCSyncSpace), "done"), + ), ) go func() { defer wg.Done() diff --git a/bar.go b/bar.go index 376c2cd..d07dc16 100644 --- a/bar.go +++ b/bar.go @@ -55,6 +55,7 @@ trimSpace bool completed bool completeFlushed bool + aborted bool triggerComplete bool dropOnComplete bool noPop bool @@ -282,6 +283,8 @@ close(done) return } + s.aborted = true + b.cancel() // container must be run during lifetime of this inner goroutine // we control this by done channel declared above go func() { @@ -302,7 +305,6 @@ } close(done) // release hold of Abort }() - b.cancel() }: // guarantee: container is alive during lifetime of this hold <-done @@ -532,6 +534,7 @@ Current: s.current, Refill: s.refill, Completed: s.completeFlushed, + Aborted: s.aborted, } } diff --git a/decor/decorator.go b/decor/decorator.go index e81fae3..9fec57b 100644 --- a/decor/decorator.go +++ b/decor/decorator.go @@ -53,6 +53,7 @@ Current int64 Refill int64 Completed bool + Aborted bool } // Decorator interface.