diff --git a/container_option.go b/container_option.go index fd0d644..da0e9b1 100644 --- a/container_option.go +++ b/container_option.go @@ -33,7 +33,7 @@ // WithRefreshRate overrides default 150ms refresh rate. func WithRefreshRate(d time.Duration) ContainerOption { return func(s *pState) { - s.rr = d + s.refreshRate = d } } diff --git a/progress.go b/progress.go index 4b94052..7328ff3 100644 --- a/progress.go +++ b/progress.go @@ -15,7 +15,7 @@ ) const ( - prr = 150 * time.Millisecond // default RefreshRate + defaultRefreshRate = 150 * time.Millisecond ) // DoneError represents an error when `*mpb.Progress` is done but its functionality is requested. @@ -46,7 +46,7 @@ pool []*Bar // following are provided/overrided by user - rr time.Duration + refreshRate time.Duration idCount int reqWidth int popPriority int @@ -73,14 +73,14 @@ // method has been called. func NewWithContext(ctx context.Context, options ...ContainerOption) *Progress { s := &pState{ - rr: prr, bHeap: priorityQueue{}, rows: make([]io.Reader, 0, 64), pool: make([]*Bar, 0, 64), + refreshRate: defaultRefreshRate, + popPriority: math.MinInt32, manualRefresh: make(chan interface{}), shutdownNotifier: make(chan struct{}), queueBars: make(map[*Bar]*Bar), - popPriority: math.MinInt32, output: os.Stdout, debugOut: io.Discard, } @@ -409,7 +409,7 @@ if s.renderDelay != nil { <-s.renderDelay } - ticker := time.NewTicker(s.rr) + ticker := time.NewTicker(s.refreshRate) defer ticker.Stop() autoRefresh = ticker.C }