diff --git a/bar.go b/bar.go index 239a583..5f6e1f7 100644 --- a/bar.go +++ b/bar.go @@ -91,10 +91,12 @@ if r == nil { panic("expected non nil io.Reader") } - result := make(chan bool) - select { - case b.operateState <- func(s *bState) { result <- len(s.ewmaDecorators) != 0 }: - return newProxyReader(r, b, <-result) + result := make(chan io.ReadCloser) + select { + case b.operateState <- func(s *bState) { + result <- newProxyReader(r, b, len(s.ewmaDecorators) != 0) + }: + return <-result case <-b.ctx.Done(): return nil } @@ -107,10 +109,12 @@ if w == nil { panic("expected non nil io.Writer") } - result := make(chan bool) - select { - case b.operateState <- func(s *bState) { result <- len(s.ewmaDecorators) != 0 }: - return newProxyWriter(w, b, <-result) + result := make(chan io.WriteCloser) + select { + case b.operateState <- func(s *bState) { + result <- newProxyWriter(w, b, len(s.ewmaDecorators) != 0) + }: + return <-result case <-b.ctx.Done(): return nil }