minor: rename rr to refreshRate
Vladimir Bauer
3 years ago
| 32 | 32 |
// WithRefreshRate overrides default 150ms refresh rate.
|
| 33 | 33 |
func WithRefreshRate(d time.Duration) ContainerOption {
|
| 34 | 34 |
return func(s *pState) {
|
| 35 | |
s.rr = d
|
|
35 |
s.refreshRate = d
|
| 36 | 36 |
}
|
| 37 | 37 |
}
|
| 38 | 38 |
|
| 14 | 14 |
)
|
| 15 | 15 |
|
| 16 | 16 |
const (
|
| 17 | |
prr = 150 * time.Millisecond // default RefreshRate
|
|
17 |
defaultRefreshRate = 150 * time.Millisecond
|
| 18 | 18 |
)
|
| 19 | 19 |
|
| 20 | 20 |
// DoneError represents an error when `*mpb.Progress` is done but its functionality is requested.
|
|
| 45 | 45 |
pool []*Bar
|
| 46 | 46 |
|
| 47 | 47 |
// following are provided/overrided by user
|
| 48 | |
rr time.Duration
|
|
48 |
refreshRate time.Duration
|
| 49 | 49 |
idCount int
|
| 50 | 50 |
reqWidth int
|
| 51 | 51 |
popPriority int
|
|
| 72 | 72 |
// method has been called.
|
| 73 | 73 |
func NewWithContext(ctx context.Context, options ...ContainerOption) *Progress {
|
| 74 | 74 |
s := &pState{
|
| 75 | |
rr: prr,
|
| 76 | 75 |
bHeap: priorityQueue{},
|
| 77 | 76 |
rows: make([]io.Reader, 0, 64),
|
| 78 | 77 |
pool: make([]*Bar, 0, 64),
|
|
78 |
refreshRate: defaultRefreshRate,
|
|
79 |
popPriority: math.MinInt32,
|
| 79 | 80 |
manualRefresh: make(chan interface{}),
|
| 80 | 81 |
shutdownNotifier: make(chan struct{}),
|
| 81 | 82 |
queueBars: make(map[*Bar]*Bar),
|
| 82 | |
popPriority: math.MinInt32,
|
| 83 | 83 |
output: os.Stdout,
|
| 84 | 84 |
debugOut: io.Discard,
|
| 85 | 85 |
}
|
|
| 408 | 408 |
if s.renderDelay != nil {
|
| 409 | 409 |
<-s.renderDelay
|
| 410 | 410 |
}
|
| 411 | |
ticker := time.NewTicker(s.rr)
|
|
411 |
ticker := time.NewTicker(s.refreshRate)
|
| 412 | 412 |
defer ticker.Stop()
|
| 413 | 413 |
autoRefresh = ticker.C
|
| 414 | 414 |
}
|