From 48206075a99e2749f193c3d2edccbfaa8c64ea47 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Tue, 1 Sep 2015 11:52:17 +0200 Subject: [PATCH] slightly different implem for `CCThread.Queue.{take,push}` --- src/threads/CCThread.ml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/threads/CCThread.ml b/src/threads/CCThread.ml index 28832fa2..753ae97d 100644 --- a/src/threads/CCThread.ml +++ b/src/threads/CCThread.ml @@ -65,8 +65,8 @@ module Queue = struct done; assert (q.size < q.capacity); Queue.push x q.q; - (* if there are blocked receivers, awake them *) - if q.size = 0 then Condition.signal q.cond; + (* if there are blocked receivers, awake one of them *) + Condition.signal q.cond; incr_size_ q; ) @@ -77,8 +77,8 @@ module Queue = struct Condition.wait q.cond q.lock done; let x = Queue.take q.q in - (* if there are blocked senders, awake them *) - if q.size = q.capacity then Condition.broadcast q.cond; + (* if there are blocked senders, awake one of them *) + Condition.signal q.cond; decr_size_ q; x )