Codebase list golang-github-vbauerster-mpb / 137c265
BarsCount method Vladimir Bauer 9 years ago
1 changed file(s) with 10 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
3838 op chan *operation
3939 rrChangeReqCh chan time.Duration
4040 outChangeReqCh chan io.Writer
41 countReqCh chan chan int
4142
4243 wg *sync.WaitGroup
4344 }
5556 op: make(chan *operation),
5657 rrChangeReqCh: make(chan time.Duration),
5758 outChangeReqCh: make(chan io.Writer),
59 countReqCh: make(chan chan int),
5860 wg: new(sync.WaitGroup),
5961 }
6062 go p.server(cwriter.New(os.Stdout), time.NewTicker(rr*time.Millisecond))
104106 return <-result
105107 }
106108
109 func (p *Progress) BarsCount() int {
110 respCh := make(chan int)
111 p.countReqCh <- respCh
112 return <-respCh
113 }
114
107115 // WaitAndStop stops listening
108116 func (p *Progress) WaitAndStop() {
109117 if !p.stopped {
146154 }
147155 op.result <- ok
148156 }
157 case respCh := <-p.countReqCh:
158 respCh <- len(bars)
149159 case <-t.C:
150160 switch p.sort {
151161 case SortTop: