diff --git a/examples/cancel/main.go b/examples/cancel/main.go index 3ff0520..5609e97 100644 --- a/examples/cancel/main.go +++ b/examples/cancel/main.go @@ -32,11 +32,11 @@ for i := 0; i < numBars; i++ { name := fmt.Sprintf("Bar#%d:", i) - startBlock := make(chan time.Time) + sbEta := make(chan time.Time) bar := p.AddBar(int64(total), mpb.PrependDecorators( decor.Name(name), - decor.ETA(decor.ET_STYLE_GO, 0, startBlock, decor.WCSyncSpace), + decor.ETA(decor.ET_STYLE_GO, 60, sbEta, decor.WCSyncSpace), ), mpb.AppendDecorators( decor.Percentage(decor.WC{W: 5}), @@ -47,7 +47,7 @@ defer wg.Done() max := 100 * time.Millisecond for !bar.Completed() { - startBlock <- time.Now() + sbEta <- time.Now() time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10) bar.Increment() } diff --git a/examples/complex/main.go b/examples/complex/main.go index a393754..3181ef6 100644 --- a/examples/complex/main.go +++ b/examples/complex/main.go @@ -44,7 +44,7 @@ doneWg.Add(1) i := i go func() { - startBlock := make(chan time.Time) + sbEta := make(chan time.Time) task := fmt.Sprintf("Task#%02d:", i) job := "installing" // preparing delayed bars @@ -54,7 +54,7 @@ mpb.PrependDecorators( decor.Name(task, decor.WC{W: len(task) + 1, C: decor.DidentRight}), decor.OnComplete(decor.Name(job, decor.WCSyncSpaceR), "done!", decor.WCSyncSpaceR), - decor.OnComplete(decor.ETA(decor.ET_STYLE_MMSS, 60, startBlock, decor.WCSyncWidth), "", decor.WCSyncSpace), + decor.OnComplete(decor.ETA(decor.ET_STYLE_MMSS, 60, sbEta, decor.WCSyncWidth), "", decor.WCSyncSpace), ), mpb.AppendDecorators( decor.OnComplete(decor.Percentage(decor.WC{W: 5}), ""), @@ -62,19 +62,19 @@ ) // waiting for download to complete, before starting install job downloadWgg[i].Wait() - go newTask(doneWg, b, numBars-i, startBlock) + go newTask(doneWg, b, numBars-i, sbEta) }() } p.Wait() } -func newTask(wg *sync.WaitGroup, b *mpb.Bar, incrBy int, startBlock chan<- time.Time) { +func newTask(wg *sync.WaitGroup, b *mpb.Bar, incrBy int, sbCh chan<- time.Time) { defer wg.Done() max := 100 * time.Millisecond for !b.Completed() { - if startBlock != nil { - startBlock <- time.Now() + if sbCh != nil { + sbCh <- time.Now() } time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10) b.IncrBy(incrBy) diff --git a/examples/prependETA/main.go b/examples/prependETA/main.go index 4e08d79..6ccf829 100644 --- a/examples/prependETA/main.go +++ b/examples/prependETA/main.go @@ -26,12 +26,12 @@ if i != 1 { name = fmt.Sprintf("Bar#%d:", i) } - startBlock := make(chan time.Time) + sbEta := make(chan time.Time) b := p.AddBar(int64(total), mpb.PrependDecorators( decor.Name(name, decor.WCSyncWidth), decor.OnComplete( - decor.ETA(decor.ET_STYLE_MMSS, 60, startBlock, decor.WC{W: 6}), + decor.ETA(decor.ET_STYLE_MMSS, 60, sbEta, decor.WC{W: 6}), "Done", decor.WCSyncSpace, ), @@ -44,7 +44,7 @@ defer wg.Done() max := 100 * time.Millisecond for i := 0; i < total; i++ { - startBlock <- time.Now() + sbEta <- time.Now() time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10) b.Increment() } diff --git a/examples/remove/main.go b/examples/remove/main.go index 0de1f2d..ea1a249 100644 --- a/examples/remove/main.go +++ b/examples/remove/main.go @@ -29,22 +29,20 @@ bOption = mpb.BarRemoveOnComplete() } - startBlock := make(chan time.Time) + sbEta := make(chan time.Time) b := p.AddBar(int64(total), mpb.BarID(i), bOption, mpb.PrependDecorators( decor.Name(name), - decor.ETA(decor.ET_STYLE_GO, 0, startBlock, decor.WCSyncSpace), + decor.ETA(decor.ET_STYLE_GO, 60, sbEta, decor.WCSyncSpace), ), - mpb.AppendDecorators( - decor.Percentage(), - ), + mpb.AppendDecorators(decor.Percentage()), ) go func() { defer wg.Done() max := 100 * time.Millisecond for i := 0; i < total; i++ { - startBlock <- time.Now() + sbEta <- time.Now() if b.ID() == 2 && i == 42 { p.Abort(b) return diff --git a/examples/sort/main.go b/examples/sort/main.go index 7178362..6062afb 100644 --- a/examples/sort/main.go +++ b/examples/sort/main.go @@ -26,21 +26,21 @@ if i != 1 { name = fmt.Sprintf("Bar#%d:", i) } - startBlock := make(chan time.Time) + sbEta := make(chan time.Time) b := p.AddBar(int64(total), mpb.PrependDecorators( decor.Name(name, decor.WCSyncWidth), decor.CountersNoUnit("%d / %d", decor.WCSyncSpace), ), mpb.AppendDecorators( - decor.ETA(decor.ET_STYLE_GO, 0, startBlock, decor.WC{W: 3}), + decor.ETA(decor.ET_STYLE_GO, 60, sbEta, decor.WC{W: 3}), ), ) go func() { defer wg.Done() max := 100 * time.Millisecond for i := 0; i < total; i++ { - startBlock <- time.Now() + sbEta <- time.Now() time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10) if i&1 == 1 { priority := total - int(b.Current()) diff --git a/examples/stress/main.go b/examples/stress/main.go index d7f59a4..53db2da 100644 --- a/examples/stress/main.go +++ b/examples/stress/main.go @@ -27,11 +27,11 @@ for i := 0; i < totalBars; i++ { name := fmt.Sprintf("Bar#%02d: ", i) total := rand.Intn(320) + 10 - startBlock := make(chan time.Time) + sbEta := make(chan time.Time) bar := p.AddBar(int64(total), mpb.PrependDecorators( decor.Name(name), - decor.ETA(decor.ET_STYLE_GO, 60, startBlock, decor.WCSyncSpace), + decor.ETA(decor.ET_STYLE_GO, 60, sbEta, decor.WCSyncSpace), ), mpb.AppendDecorators( decor.Percentage(decor.WC{W: 5}), @@ -42,7 +42,7 @@ defer wg.Done() max := 100 * time.Millisecond for !bar.Completed() { - startBlock <- time.Now() + sbEta <- time.Now() time.Sleep(time.Duration(rand.Intn(10)+1) * max / 10) bar.Increment() }