Codebase list golang-github-vbauerster-mpb / 561d559
Pass *bState intead of bState Vladimir Bauer 8 years ago
1 changed file(s) with 5 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
3535 ops chan func(*bState)
3636
3737 // following are used after b.done is receiveable
38 cacheState bState
38 cacheState *bState
3939
4040 once sync.Once
4141 }
7979 total = time.Now().Unix()
8080 }
8181
82 s := bState{
82 s := &bState{
8383 id: ID,
8484 total: total,
8585 etaAlpha: etaAlpha,
8787 }
8888
8989 for _, opt := range options {
90 opt(&s)
90 opt(s)
9191 }
9292
9393 s.bufP = bytes.NewBuffer(make([]byte, 0, s.width/2))
265265 close(b.quit)
266266 }
267267
268 func (b *Bar) server(s bState, wg *sync.WaitGroup, cancel <-chan struct{}) {
268 func (b *Bar) server(s *bState, wg *sync.WaitGroup, cancel <-chan struct{}) {
269269 defer func() {
270270 b.cacheState = s
271271 close(b.done)
275275 for {
276276 select {
277277 case op := <-b.ops:
278 op(&s)
278 op(s)
279279 case <-cancel:
280280 s.aborted = true
281281 cancel = nil