mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-11 13:38:38 -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 =
|
let pop (self : 'a t) : 'a =
|
||||||
Mutex.lock self.mutex;
|
Mutex.lock self.mutex;
|
||||||
let rec loop () =
|
let rec loop () =
|
||||||
if self.closed then (
|
if Queue.is_empty self.q then (
|
||||||
Mutex.unlock self.mutex;
|
if self.closed then (
|
||||||
raise Closed
|
Mutex.unlock self.mutex;
|
||||||
) else if Queue.is_empty self.q then (
|
raise Closed
|
||||||
|
);
|
||||||
|
|
||||||
Condition.wait self.cond self.mutex;
|
Condition.wait self.cond self.mutex;
|
||||||
(loop [@tailcall]) ()
|
(loop [@tailcall]) ()
|
||||||
) else (
|
) else (
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue