Codebase list golang-github-vbauerster-mpb / 8fc67c8
run eash AverageAdjust from within b.serve It's not common to call DecoratorAverageAdjust frequently, usually it's called once presumably after some retry. Calling each d.AverageAdjust in new goroutine requires extra sync bookkeeping which is overhead for an average based decorators. Vladimir Bauer 1 year, 10 months ago
1 changed file(s) with 6 addition(s) and 20 deletion(s). Raw diff Collapse all Expand all
322322 // if you need to adjust start time of all average based decorators
323323 // or after progress resume.
324324 func (b *Bar) DecoratorAverageAdjust(start time.Time) {
325 result := make(chan *sync.WaitGroup)
326 select {
327 case b.operateState <- func(s *bState) {
328 var wg sync.WaitGroup
329 s.decoratorAverageAdjust(start, &wg)
330 result <- &wg
331 }:
332 wg := <-result
333 wg.Wait()
325 select {
326 case b.operateState <- func(s *bState) {
327 for _, d := range s.averageDecorators {
328 d.AverageAdjust(start)
329 }
330 }:
334331 case <-b.ctx.Done():
335332 }
336333 }
590587 }
591588 }
592589
593 func (s bState) decoratorAverageAdjust(start time.Time, wg *sync.WaitGroup) {
594 wg.Add(len(s.averageDecorators))
595 for _, d := range s.averageDecorators {
596 d := d
597 go func() {
598 d.AverageAdjust(start)
599 wg.Done()
600 }()
601 }
602 }
603
604590 func (s bState) decoratorShutdownNotify(wg *sync.WaitGroup) {
605591 wg.Add(len(s.shutdownListeners))
606592 for _, d := range s.shutdownListeners {