slightly different implem for CCThread.Queue.{take,push}

This commit is contained in:
Simon Cruanes 2015-09-01 11:52:17 +02:00
parent 5af816fe9b
commit 48206075a9

View file

@ -65,8 +65,8 @@ module Queue = struct
done; done;
assert (q.size < q.capacity); assert (q.size < q.capacity);
Queue.push x q.q; Queue.push x q.q;
(* if there are blocked receivers, awake them *) (* if there are blocked receivers, awake one of them *)
if q.size = 0 then Condition.signal q.cond; Condition.signal q.cond;
incr_size_ q; incr_size_ q;
) )
@ -77,8 +77,8 @@ module Queue = struct
Condition.wait q.cond q.lock Condition.wait q.cond q.lock
done; done;
let x = Queue.take q.q in let x = Queue.take q.q in
(* if there are blocked senders, awake them *) (* if there are blocked senders, awake one of them *)
if q.size = q.capacity then Condition.broadcast q.cond; Condition.signal q.cond;
decr_size_ q; decr_size_ q;
x x
) )