Codebase list golang-github-vbauerster-mpb / 91edfaf
signal to flushedCh directly Vladimir Bauer 9 years ago
2 changed file(s) with 12 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
180180 return b
181181 }
182182
183 func (b *Bar) AppendPercentage() *Bar {
184 b.AppendFunc(func(s *Statistics) string {
185 completed := int(100 * float64(s.Completed) / float64(s.Total))
186 return fmt.Sprintf("%3d %%", completed)
187 })
188 return b
189 }
190
183191 func (b *Bar) PrependPercentage() *Bar {
184192 b.PrependFunc(func(s *Statistics) string {
185193 completed := int(100 * float64(s.Completed) / float64(s.Total))
186 return fmt.Sprintf("%3d %%", completed)
194 str := fmt.Sprintf("%3d %%", completed)
195 return fmt.Sprintf("%-5s", str)
187196 })
188197 return b
189198 }
272281 return buf
273282 }
274283
275 func (b *Bar) flushed() {
276 b.flushedCh <- struct{}{}
277 }
278
279284 func (b *Bar) updateTimePerItemEstimate(items int, blockStartTime time.Time) {
280285 lastBlockTime := time.Since(blockStartTime)
281286 lastItemEstimate := float64(lastBlockTime) / float64(items)
2424 width int
2525 stopped bool
2626
27 op chan *operation
28
27 op chan *operation
2928 rrChangeReqCh chan time.Duration
3029
3130 wg *sync.WaitGroup
137136 lw.Flush()
138137 for _, b := range bars {
139138 go func(b *Bar) {
140 b.flushed()
139 b.flushedCh <- struct{}{}
141140 }(b)
142141 }
143142 case d := <-p.rrChangeReqCh: