| 24 | 24 |
cancel func()
|
| 25 | 25 |
}
|
| 26 | 26 |
|
|
27 |
type syncTable [2][]chan int
|
| 27 | 28 |
type extenderFunc func([]io.Reader, decor.Statistics) ([]io.Reader, error)
|
| 28 | 29 |
|
| 29 | 30 |
// bState is actual bar's state.
|
|
| 469 | 470 |
}
|
| 470 | 471 |
}
|
| 471 | 472 |
|
| 472 | |
func (b *Bar) wSyncTable() [][]chan int {
|
| 473 | |
result := make(chan [][]chan int)
|
|
473 |
func (b *Bar) wSyncTable() syncTable {
|
|
474 |
result := make(chan syncTable)
|
| 474 | 475 |
select {
|
| 475 | 476 |
case b.operateState <- func(s *bState) { result <- s.wSyncTable() }:
|
| 476 | 477 |
return <-result
|
|
| 558 | 559 |
return io.MultiReader(bufP, bufB, bufA), nil
|
| 559 | 560 |
}
|
| 560 | 561 |
|
| 561 | |
func (s *bState) wSyncTable() [][]chan int {
|
| 562 | |
columns := make([]chan int, 0, len(s.pDecorators)+len(s.aDecorators))
|
| 563 | |
var pCount int
|
| 564 | |
for _, d := range s.pDecorators {
|
| 565 | |
if ch, ok := d.Sync(); ok {
|
| 566 | |
columns = append(columns, ch)
|
| 567 | |
pCount++
|
| 568 | |
}
|
| 569 | |
}
|
| 570 | |
var aCount int
|
| 571 | |
for _, d := range s.aDecorators {
|
| 572 | |
if ch, ok := d.Sync(); ok {
|
| 573 | |
columns = append(columns, ch)
|
| 574 | |
aCount++
|
| 575 | |
}
|
| 576 | |
}
|
| 577 | |
table := make([][]chan int, 2)
|
| 578 | |
table[0] = columns[0:pCount]
|
| 579 | |
table[1] = columns[pCount : pCount+aCount : pCount+aCount]
|
|
562 |
func (s *bState) wSyncTable() (table syncTable) {
|
|
563 |
var count int
|
|
564 |
var row []chan int
|
|
565 |
|
|
566 |
for i, decorators := range [][]decor.Decorator{
|
|
567 |
s.pDecorators,
|
|
568 |
s.aDecorators,
|
|
569 |
} {
|
|
570 |
for _, d := range decorators {
|
|
571 |
if ch, ok := d.Sync(); ok {
|
|
572 |
row = append(row, ch)
|
|
573 |
count++
|
|
574 |
}
|
|
575 |
}
|
|
576 |
switch i {
|
|
577 |
case 0:
|
|
578 |
table[i] = row[0:count]
|
|
579 |
default:
|
|
580 |
table[i] = row[len(table[i-1]):count]
|
|
581 |
}
|
|
582 |
}
|
| 580 | 583 |
return table
|
| 581 | 584 |
}
|
| 582 | 585 |
|