Codebase list golang-github-vbauerster-mpb / c75881d
cmdValue is chan int64 Vladimir Bauer 7 years ago
1 changed file(s) with 13 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
4141 runningBar *Bar
4242 cacheState *bState
4343 operateState chan func(*bState)
44 cmdValue chan int
44 cmdValue chan int64
4545 frameReaderCh chan io.Reader
4646
4747 // done is closed by Bar's goroutine, after cacheState is written
116116 priority: s.priority,
117117 runningBar: s.runningBar,
118118 operateState: make(chan func(*bState)),
119 cmdValue: make(chan int),
119 cmdValue: make(chan int64),
120120 frameReaderCh: make(chan io.Reader, 1),
121121 done: make(chan struct{}),
122122 shutdown: make(chan struct{}),
159159 func (b *Bar) NumOfAppenders() int {
160160 select {
161161 case b.cmdValue <- cmdALen:
162 return <-b.cmdValue
162 return int(<-b.cmdValue)
163163 case <-b.done:
164164 return len(b.cacheState.aDecorators)
165165 }
169169 func (b *Bar) NumOfPrependers() int {
170170 select {
171171 case b.cmdValue <- cmdPLen:
172 return <-b.cmdValue
172 return int(<-b.cmdValue)
173173 case <-b.done:
174174 return len(b.cacheState.pDecorators)
175175 }
179179 func (b *Bar) ID() int {
180180 select {
181181 case b.cmdValue <- cmdId:
182 return <-b.cmdValue
182 return int(<-b.cmdValue)
183183 case <-b.done:
184184 return b.cacheState.id
185185 }
189189 func (b *Bar) Current() int64 {
190190 select {
191191 case b.cmdValue <- cmdCurrent:
192 return int64(<-b.cmdValue)
192 return <-b.cmdValue
193193 case <-b.done:
194194 return b.cacheState.current
195195 }
199199 func (b *Bar) Total() int64 {
200200 select {
201201 case b.cmdValue <- cmdTotal:
202 return int64(<-b.cmdValue)
202 return <-b.cmdValue
203203 case <-b.done:
204204 return b.cacheState.total
205205 }
272272 case cmd := <-b.cmdValue:
273273 switch {
274274 case cmd&cmdId != 0:
275 b.cmdValue <- s.id
275 b.cmdValue <- int64(s.id)
276276 case cmd&cmdTotal != 0:
277 b.cmdValue <- int(s.total)
277 b.cmdValue <- s.total
278278 case cmd&cmdCurrent != 0:
279 b.cmdValue <- int(s.current)
279 b.cmdValue <- s.current
280280 case cmd&cmdPLen != 0:
281 b.cmdValue <- len(s.pDecorators)
281 b.cmdValue <- int64(len(s.pDecorators))
282282 case cmd&cmdALen != 0:
283 b.cmdValue <- len(s.aDecorators)
283 b.cmdValue <- int64(len(s.aDecorators))
284284 case cmd&cmdCompleted != 0:
285 var v int
285 var v int64
286286 if s.toComplete {
287287 v = 1
288288 }