Fix wait condition and ordering in send().
This commit is contained in:
parent
4052afa31d
commit
c4e92faaf7
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user