mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
slightly different implem for CCThread.Queue.{take,push}
This commit is contained in:
parent
5af816fe9b
commit
48206075a9
1 changed files with 4 additions and 4 deletions
|
|
@ -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
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue