Codebase list golang-github-vbauerster-mpb / 48a6a80
refactoring: defer inside if Vladimir Bauer 7 years ago
1 changed file(s) with 7 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
264264 bm := make(map[*Bar]struct{}, s.bHeap.Len())
265265 for s.bHeap.Len() > 0 {
266266 b := heap.Pop(&s.bHeap).(*Bar)
267 defer func() {
268 if b.toShutdown {
269 // shutdown at next flush, in other words decrement underlying WaitGroup
270 // only after the bar with completed state has been flushed. this
271 // ensures no bar ends up with less than 100% rendered.
267 cw.ReadFrom(<-b.frameCh)
268 if b.toShutdown {
269 // shutdown at next flush
270 // this ensures no bar ends up with less than 100% rendered
271 defer func() {
272272 s.barShutdownQueue = append(s.barShutdownQueue, b)
273273 if !b.noPop && s.popCompleted {
274274 b.priority = -1
275275 }
276 }
277 }()
278 cw.ReadFrom(<-b.frameCh)
276 }()
277 }
279278 lineCount += b.extendedLines + 1
280279 bm[b] = struct{}{}
281280 }