Codebase list golang-github-vbauerster-mpb / ea8db49
IncrInt64 method Vladimir Bauer 7 years ago
4 changed file(s) with 17 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
202202 b.arbitraryCurrent.Unlock()
203203 }
204204
205 // Increment is a shorthand for b.IncrBy(1).
206 func (b *Bar) Increment() {
207 b.IncrBy(1)
208 }
209
210 // IncrBy increments progress bar by amount of n.
211 // wdd is optional work duration i.e. time.Since(start), which expected
212 // to be provided, if any ewma based decorator is used.
205 // Increment is a shorthand for b.IncrInt64(1).
206 func (b *Bar) Increment(wdd ...time.Duration) {
207 b.IncrInt64(1, wdd...)
208 }
209
210 // IncrBy is a shorthand for b.IncrInt64(int64(n), wdd...).
213211 func (b *Bar) IncrBy(n int, wdd ...time.Duration) {
212 b.IncrInt64(int64(n), wdd...)
213 }
214
215 // IncrInt64 increments progress bar by amount of n. wdd is an optional
216 // work duration i.e. time.Since(start), which expected to be passed,
217 // if any ewma based decorator is used.
218 func (b *Bar) IncrInt64(n int64, wdd ...time.Duration) {
214219 select {
215220 case b.operateState <- func(s *bState) {
216 s.current += int64(n)
221 s.current += n
217222 if s.total > 0 && s.current >= s.total {
218223 s.current = s.total
219224 s.toComplete = true
8282 // If decorator needs to receive increment amount, so this is the right
8383 // interface to implement.
8484 type AmountReceiver interface {
85 NextAmount(int, ...time.Duration)
85 NextAmount(int64, ...time.Duration)
8686 }
8787
8888 // ShutdownListener interface.
9797 return d.FormatMsg(str)
9898 }
9999
100 func (d *movingAverageETA) NextAmount(n int, wdd ...time.Duration) {
100 func (d *movingAverageETA) NextAmount(n int64, wdd ...time.Duration) {
101101 var workDuration time.Duration
102102 for _, wd := range wdd {
103103 workDuration = wd
191191 return d.FormatMsg(d.msg)
192192 }
193193
194 func (d *movingAverageSpeed) NextAmount(n int, wdd ...time.Duration) {
194 func (d *movingAverageSpeed) NextAmount(n int64, wdd ...time.Duration) {
195195 var workDuration time.Duration
196196 for _, wd := range wdd {
197197 workDuration = wd