Codebase list golang-github-vbauerster-mpb / 489cb05
proof of width sync conept Vladimir Bauer 9 years ago
2 changed file(s) with 10 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
246246 if isClosed(b.done) {
247247 return b.state
248248 }
249 ch := make(chan state, 1)
249 // ch := make(chan state, 1)
250 ch := make(chan state)
250251 b.stateReqCh <- ch
251252 return <-ch
252253 }
357358 }
358359
359360 func draw(s *state, termWidth int, ws *widthSync) []byte {
361 if len(s.prependFuncs) != len(ws.listen) {
362 return []byte{}
363 }
360364 if termWidth <= 0 {
361365 termWidth = s.width
362366 }
296296 for i := 0; i < numBars; i++ {
297297 resultCh <- result
298298 }
299 // close(resultCh)
299 close(resultCh)
300300 }(listenCh, prepWidthSync.result[i])
301301 }
302302
306306 wg.Add(numBars)
307307 for i := 0; i < numBars; i++ {
308308 go func() {
309 defer recoverIfPanic()
309 // defer recoverIfPanic()
310 defer func() {
311 wg.Done()
312 }()
310313 drawer(ibars, ibbCh, prepWidthSync)
311314 }()
312315 }
314317 wg.Wait()
315318 close(ibbCh)
316319 close(stopWidthListen)
317 for _, ch := range prepWidthSync.result {
318 close(ch)
319 }
320320 for _, ch := range prepWidthSync.listen {
321321 close(ch)
322322 }