Codebase list golang-github-vbauerster-mpb / 0925dc8
refactoring: total bar waits for last doneTasks update Vladimir Bauer 3 years ago
1 changed file(s) with 6 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
5959 tasks[i].bar = bar
6060 }
6161
62 tb := p.AddBar(int64(total),
62 tb := p.AddBar(0,
6363 mpb.PrependDecorators(
6464 decor.Any(func(st decor.Statistics) string {
65 var done uint32
66 if st.Completed {
67 done = uint32(len(tasks))
68 } else {
69 done = atomic.LoadUint32(&doneTasks)
70 }
71 return fmt.Sprintf("TOTAL(%d/%d)", done, len(tasks))
65 return fmt.Sprintf("TOTAL(%d/%d)", atomic.LoadUint32(&doneTasks), len(tasks))
7266 }, decor.WCSyncWidthR),
7367 ),
7468 mpb.AppendDecorators(
7670 ),
7771 )
7872
73 tb.SetTotal(int64(total), false)
74
7975 for _, t := range tasks {
8076 atomic.StoreUint32(&curTask, uint32(t.id))
8177 complete(tb, t)
8278 atomic.AddUint32(&doneTasks, 1)
8379 }
80
81 tb.EnableTriggerComplete()
8482
8583 p.Wait()
8684 }