refactor const RefreshRate
Vladimir Bauer
9 years ago
| 25 | 25 | SortBottom |
| 26 | 26 | ) |
| 27 | 27 | |
| 28 | const refreshRate = 100 | |
| 28 | // RefreshRate | |
| 29 | const rr = 100 | |
| 29 | 30 | |
| 30 | 31 | // Progress represents the container that renders Progress bars |
| 31 | 32 | type Progress struct { |
| 56 | 57 | outChangeReqCh: make(chan io.Writer), |
| 57 | 58 | wg: new(sync.WaitGroup), |
| 58 | 59 | } |
| 59 | go p.server(cwriter.New(os.Stdout)) | |
| 60 | go p.server(cwriter.New(os.Stdout), time.NewTicker(rr*time.Millisecond)) | |
| 60 | 61 | return p |
| 61 | 62 | } |
| 62 | 63 | |
| 114 | 115 | } |
| 115 | 116 | |
| 116 | 117 | // server monitors underlying channels and renders any progress bars |
| 117 | func (p *Progress) server(cw *cwriter.Writer) { | |
| 118 | t := time.NewTicker(refreshRate * time.Millisecond) | |
| 118 | func (p *Progress) server(cw *cwriter.Writer, t *time.Ticker) { | |
| 119 | 119 | bars := make([]*Bar, 0, 4) |
| 120 | 120 | for { |
| 121 | 121 | select { |