avoid panic, if Wait called more than once
Vladimir Bauer
7 years ago
| 29 | 29 | operateState chan func(*pState) |
| 30 | 30 | done chan struct{} |
| 31 | 31 | forceRefresh chan time.Time |
| 32 | once sync.Once | |
| 32 | 33 | dlogger *log.Logger |
| 33 | 34 | } |
| 34 | 35 | |
| 204 | 205 | // wait for bars to quit, if any |
| 205 | 206 | p.bwg.Wait() |
| 206 | 207 | |
| 207 | close(p.done) | |
| 208 | p.once.Do(p.shutdown) | |
| 208 | 209 | |
| 209 | 210 | // wait for container to quit |
| 210 | 211 | p.cwg.Wait() |
| 212 | } | |
| 213 | ||
| 214 | func (p *Progress) shutdown() { | |
| 215 | close(p.done) | |
| 211 | 216 | } |
| 212 | 217 | |
| 213 | 218 | func (p *Progress) serve(s *pState, cw *cwriter.Writer) { |