Codebase list golang-github-vbauerster-mpb / d690365
some comments for future self Vladimir Bauer 8 years ago
1 changed file(s) with 7 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
215215 bf := <-ch
216216 _, err = s.cw.ReadFrom(bf.reader)
217217 if !bf.bar.completed && bf.toComplete {
218 bf.bar.completed = true
218 // shutdown at next flush, in other words decrement underlying WaitGroup
219 // only after the bar with completed state has been flushed.
220 // this ensures no bar ends up with less than 100% rendered.
221 defer func() {
222 s.shutdownPending = append(s.shutdownPending, bf.bar)
223 }()
219224 if bf.bar.removeOnComplete {
220225 s.heapUpdated = heap.Remove(s.bHeap, bf.bar.index) != nil
221226 }
224229 s.heapUpdated = true
225230 delete(s.waitBars, bf.bar)
226231 }
227 // defer is required to make removeOnComplete visually happen
228 defer func() {
229 s.shutdownPending = append(s.shutdownPending, bf.bar)
230 }()
232 bf.bar.completed = true
231233 }
232234 }
233235