mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-09 20:55:35 -05:00
Merge 01cdb66f1f into d957f7b54e
This commit is contained in:
commit
7c64ad9400
1 changed files with 22 additions and 13 deletions
|
|
@ -15,19 +15,23 @@ module Bb_queue = struct
|
|||
if was_empty then Condition.broadcast self.cond;
|
||||
Mutex.unlock self.mutex
|
||||
|
||||
let pop (self : 'a t) : 'a =
|
||||
let pop (type a) (self : a t) : a =
|
||||
let module M = struct
|
||||
exception Found of a
|
||||
end in
|
||||
try
|
||||
Mutex.lock self.mutex;
|
||||
let rec loop () =
|
||||
if Queue.is_empty self.q then (
|
||||
Condition.wait self.cond self.mutex;
|
||||
(loop [@tailcall]) ()
|
||||
) else (
|
||||
while true do
|
||||
if Queue.is_empty self.q then
|
||||
Condition.wait self.cond self.mutex
|
||||
else (
|
||||
let x = Queue.pop self.q in
|
||||
Mutex.unlock self.mutex;
|
||||
x
|
||||
raise (M.Found x)
|
||||
)
|
||||
in
|
||||
loop ()
|
||||
done;
|
||||
assert false
|
||||
with M.Found x -> x
|
||||
end
|
||||
|
||||
module Lock = struct
|
||||
|
|
@ -95,6 +99,11 @@ let domains_ : (worker_state option * Domain_.t option) Lock.t array =
|
|||
a [Pool.with_] or [Pool.create() … Pool.shutdown()] in a tight loop), and
|
||||
if nothing happens it tries to stop to free resources. *)
|
||||
let work_ idx (st : worker_state) : unit =
|
||||
Thread.sigmask SIG_BLOCK
|
||||
[
|
||||
Sys.sigpipe; Sys.sigbus; Sys.sigterm; Sys.sigint; Sys.sigusr1; Sys.sigusr2;
|
||||
]
|
||||
|> ignore;
|
||||
let main_loop () =
|
||||
let continue = ref true in
|
||||
while !continue do
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue