mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-10 05:03:58 -05:00
fix: in blocking queue, pop works on a non empty closed queue
This commit is contained in:
parent
4e112e1591
commit
67bc47181c
1 changed files with 6 additions and 4 deletions
|
|
@ -37,10 +37,12 @@ let push (self : _ t) x : unit =
|
|||
let pop (self : 'a t) : 'a =
|
||||
Mutex.lock self.mutex;
|
||||
let rec loop () =
|
||||
if self.closed then (
|
||||
Mutex.unlock self.mutex;
|
||||
raise Closed
|
||||
) else if Queue.is_empty self.q then (
|
||||
if Queue.is_empty self.q then (
|
||||
if self.closed then (
|
||||
Mutex.unlock self.mutex;
|
||||
raise Closed
|
||||
);
|
||||
|
||||
Condition.wait self.cond self.mutex;
|
||||
(loop [@tailcall]) ()
|
||||
) else (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue