Codebase list golang-github-vbauerster-mpb / c822af1
More precise barState.startTime Vladimir Bauer 9 years ago
1 changed file(s) with 10 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
272272 }
273273
274274 func (b *Bar) server(id int, total int64, width int, format string, wg *sync.WaitGroup, cancel <-chan struct{}) {
275 incrStartTime := time.Now()
275 var incrStartTime time.Time
276276 barState := state{
277 id: id,
278 width: width,
279 format: barFmtRunes{'[', '=', '>', '-', ']'},
280 etaAlpha: 0.25,
281 total: total,
282 startTime: incrStartTime,
283 completed: false,
277 id: id,
278 width: width,
279 format: barFmtRunes{'[', '=', '>', '-', ']'},
280 etaAlpha: 0.25,
281 total: total,
284282 }
285283 if total <= 0 {
286284 barState.simpleSpinner = getSpinner()
294292 for {
295293 select {
296294 case barState.incrAmount = <-b.incrCh:
295 if barState.current == 0 {
296 incrStartTime = time.Now()
297 barState.startTime = incrStartTime
298 }
297299 n := barState.current + barState.incrAmount
298300 if total > 0 && n > total {
299301 barState.current = total