Codebase list golang-github-vbauerster-mpb / 8dd56fd
Issue #7: call b.Completed() implicitly, if total <= 0 Vladimir Bauer 9 years ago
1 changed file(s) with 12 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
6464 barCountReqCh chan chan int
6565 brCh chan BeforeRender
6666 done chan struct{}
67 beforeStop chan struct{}
6768 cancel <-chan struct{}
6869 }
6970
7980 barCountReqCh: make(chan chan int),
8081 brCh: make(chan BeforeRender),
8182 done: make(chan struct{}),
83 beforeStop: make(chan struct{}),
8284 wg: new(sync.WaitGroup),
8385 }
8486 go p.server()
197199 // 100 %. It is NOT for cancelation. Use WithContext or WithCancel for
198200 // cancelation purposes.
199201 func (p *Progress) Stop() {
202 if isClosed(p.done) {
203 return
204 }
205 p.beforeStop <- struct{}{}
200206 p.wg.Wait()
201 if isClosed(p.done) {
202 return
203 }
204207 close(p.bCommandCh)
205208 }
206209
297300 case userRR = <-p.rrChangeReqCh:
298301 t.Stop()
299302 t = time.NewTicker(userRR)
303 case <-p.beforeStop:
304 for _, b := range bars {
305 if b.GetStatistics().Total <= 0 {
306 b.Completed()
307 }
308 }
300309 case <-p.cancel:
301310 return
302311 }