diff --git a/precise/lib.go b/precise/lib.go index 171f1fb..82fa01d 100644 --- a/precise/lib.go +++ b/precise/lib.go @@ -138,12 +138,12 @@ func (s *state[T]) send(value T, buf *circ.B[T], cond *sync.Cond) { s.mu.Lock() defer s.mu.Unlock() for { + for !s.closed && !buf.CanPush() { + cond.Wait() + } if s.closed { panic("send on closed queue") } - for !buf.CanPush() { - cond.Wait() - } if buf.CanPush() { buf.PushBack(value) s.canRecv.Broadcast()