abandon width sync after rr passed
Vladimir Bauer
9 years ago
| 274 | 274 | beforeRender(bars) |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | stopWidthListen := make(chan struct{}) | |
| 278 | prependWs := newWidthSync(stopWidthListen, numBars, bars[0].NumOfPrependers()) | |
| 279 | appendWs := newWidthSync(stopWidthListen, numBars, bars[0].NumOfAppenders()) | |
| 277 | prependWs := newWidthSync(numBars, bars[0].NumOfPrependers()) | |
| 278 | appendWs := newWidthSync(numBars, bars[0].NumOfAppenders()) | |
| 280 | 279 | |
| 281 | 280 | width, _, _ := cwriter.GetTermSize() |
| 282 | 281 | ibars := iBarsGen(bars, width) |
| 291 | 290 | go func() { |
| 292 | 291 | wg.Wait() |
| 293 | 292 | close(ibbCh) |
| 294 | close(stopWidthListen) | |
| 295 | 293 | for _, ch := range prependWs.listen { |
| 296 | 294 | close(ch) |
| 297 | 295 | } |
| 322 | 320 | } |
| 323 | 321 | } |
| 324 | 322 | |
| 325 | func newWidthSync(stopListen chan struct{}, numBars, numColumn int) *widthSync { | |
| 323 | func newWidthSync(numBars, numColumn int) *widthSync { | |
| 326 | 324 | ws := &widthSync{ |
| 327 | 325 | listen: make([]chan int, numColumn), |
| 328 | 326 | result: make([]chan int, numColumn), |
| 343 | 341 | if len(widths) == numBars { |
| 344 | 342 | break loop |
| 345 | 343 | } |
| 346 | case <-stopListen: | |
| 344 | case <-time.After(rr * time.Millisecond): | |
| 347 | 345 | return |
| 348 | 346 | } |
| 349 | 347 | } |