Codebase list golang-github-vbauerster-mpb / fbc6960
unblocking SetTotal Vladimir Bauer 7 years ago
1 changed file(s) with 7 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
178178
179179 // SetTotal sets total dynamically.
180180 // Set final to true, when total is known, it will trigger bar complete event.
181 func (b *Bar) SetTotal(total int64, final bool) {
182 b.operateState <- func(s *bState) {
181 func (b *Bar) SetTotal(total int64, final bool) bool {
182 select {
183 case b.operateState <- func(s *bState) {
183184 if total > 0 {
184185 s.total = total
185186 }
187188 s.current = s.total
188189 s.toComplete = true
189190 }
191 }:
192 return true
193 case <-b.done:
194 return false
190195 }
191196 }
192197