IncrInt64 method
Vladimir Bauer
7 years ago
| 202 | 202 |
b.arbitraryCurrent.Unlock()
|
| 203 | 203 |
}
|
| 204 | 204 |
|
| 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...).
|
| 213 | 211 |
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) {
|
| 214 | 219 |
select {
|
| 215 | 220 |
case b.operateState <- func(s *bState) {
|
| 216 | |
s.current += int64(n)
|
|
221 |
s.current += n
|
| 217 | 222 |
if s.total > 0 && s.current >= s.total {
|
| 218 | 223 |
s.current = s.total
|
| 219 | 224 |
s.toComplete = true
|
| 82 | 82 |
// If decorator needs to receive increment amount, so this is the right
|
| 83 | 83 |
// interface to implement.
|
| 84 | 84 |
type AmountReceiver interface {
|
| 85 | |
NextAmount(int, ...time.Duration)
|
|
85 |
NextAmount(int64, ...time.Duration)
|
| 86 | 86 |
}
|
| 87 | 87 |
|
| 88 | 88 |
// ShutdownListener interface.
|
| 97 | 97 |
return d.FormatMsg(str)
|
| 98 | 98 |
}
|
| 99 | 99 |
|
| 100 | |
func (d *movingAverageETA) NextAmount(n int, wdd ...time.Duration) {
|
|
100 |
func (d *movingAverageETA) NextAmount(n int64, wdd ...time.Duration) {
|
| 101 | 101 |
var workDuration time.Duration
|
| 102 | 102 |
for _, wd := range wdd {
|
| 103 | 103 |
workDuration = wd
|
| 191 | 191 |
return d.FormatMsg(d.msg)
|
| 192 | 192 |
}
|
| 193 | 193 |
|
| 194 | |
func (d *movingAverageSpeed) NextAmount(n int, wdd ...time.Duration) {
|
|
194 |
func (d *movingAverageSpeed) NextAmount(n int64, wdd ...time.Duration) {
|
| 195 | 195 |
var workDuration time.Duration
|
| 196 | 196 |
for _, wd := range wdd {
|
| 197 | 197 |
workDuration = wd
|