make result chan inside wSyncTable
there is no win in keeping it on bar instance.
Vladimir Bauer
4 years ago
| 25 | 25 | hasEwmaDecorators bool |
| 26 | 26 | operateState chan func(*bState) |
| 27 | 27 | frameCh chan *frame |
| 28 | syncTableCh chan [][]chan int | |
| 29 | 28 | |
| 30 | 29 | // cancel is called either by user or on complete event |
| 31 | 30 | cancel func() |
| 90 | 89 | noPop: bs.noPop, |
| 91 | 90 | operateState: make(chan func(*bState)), |
| 92 | 91 | frameCh: make(chan *frame, 1), |
| 93 | syncTableCh: make(chan [][]chan int, 1), | |
| 94 | 92 | done: make(chan struct{}), |
| 95 | 93 | cancel: cancel, |
| 96 | 94 | dlogger: log.New(bs.debugOut, logPrefix, log.Lshortfile), |
| 383 | 381 | } |
| 384 | 382 | |
| 385 | 383 | func (b *Bar) wSyncTable() [][]chan int { |
| 386 | select { | |
| 387 | case b.operateState <- func(s *bState) { b.syncTableCh <- s.wSyncTable() }: | |
| 388 | return <-b.syncTableCh | |
| 384 | result := make(chan [][]chan int) | |
| 385 | select { | |
| 386 | case b.operateState <- func(s *bState) { result <- s.wSyncTable() }: | |
| 387 | return <-result | |
| 389 | 388 | case <-b.done: |
| 390 | 389 | return b.cacheState.wSyncTable() |
| 391 | 390 | } |