Codebase list golang-github-vbauerster-mpb / 741cad7
rename param to iterDur so it's clear what kind of duration it is. Vladimir Bauer 3 years ago
1 changed file(s) with 12 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
238238
239239 // EwmaSetCurrent sets progress' current to an arbitrary value and updates
240240 // EWMA based decorators by dur of a single iteration.
241 func (b *Bar) EwmaSetCurrent(current int64, dur time.Duration) {
241 func (b *Bar) EwmaSetCurrent(current int64, iterDur time.Duration) {
242242 if current < 0 {
243243 return
244244 }
245245 select {
246246 case b.operateState <- func(s *bState) {
247247 if n := current - s.current; n > 0 {
248 s.ewmaUpdate(n, dur)
248 s.ewmaUpdate(n, iterDur)
249249 }
250250 s.current = current
251251 if s.triggerComplete && s.current >= s.total {
286286 }
287287 }
288288
289 // EwmaIncrement is a shorthand for b.EwmaIncrInt64(1, dur).
290 func (b *Bar) EwmaIncrement(dur time.Duration) {
291 b.EwmaIncrInt64(1, dur)
292 }
293
294 // EwmaIncrBy is a shorthand for b.EwmaIncrInt64(int64(n), dur).
295 func (b *Bar) EwmaIncrBy(n int, dur time.Duration) {
296 b.EwmaIncrInt64(int64(n), dur)
289 // EwmaIncrement is a shorthand for b.EwmaIncrInt64(1, iterDur).
290 func (b *Bar) EwmaIncrement(iterDur time.Duration) {
291 b.EwmaIncrInt64(1, iterDur)
292 }
293
294 // EwmaIncrBy is a shorthand for b.EwmaIncrInt64(int64(n), iterDur).
295 func (b *Bar) EwmaIncrBy(n int, iterDur time.Duration) {
296 b.EwmaIncrInt64(int64(n), iterDur)
297297 }
298298
299299 // EwmaIncrInt64 increments progress by amount of n and updates EWMA based
300300 // decorators by dur of a single iteration.
301 func (b *Bar) EwmaIncrInt64(n int64, dur time.Duration) {
301 func (b *Bar) EwmaIncrInt64(n int64, iterDur time.Duration) {
302302 if n <= 0 {
303303 return
304304 }
305305 select {
306306 case b.operateState <- func(s *bState) {
307 s.ewmaUpdate(n, dur)
307 s.ewmaUpdate(n, iterDur)
308308 s.current += n
309309 if s.triggerComplete && s.current >= s.total {
310310 s.current = s.total