mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-12 14:00:41 -05:00
pool: do some spinning in run, not in workers
This commit is contained in:
parent
939c6e117c
commit
82af5497f8
1 changed files with 6 additions and 8 deletions
14
src/pool.ml
14
src/pool.ml
|
|
@ -39,7 +39,7 @@ let run (self : t) (f : task) : unit =
|
|||
|
||||
try
|
||||
(* try each queue with a round-robin initial offset *)
|
||||
for _retry = 1 to 3 do
|
||||
for _retry = 1 to 10 do
|
||||
for i = 0 to n_qs - 1 do
|
||||
let q_idx = (i + offset) mod Array.length self.qs in
|
||||
let q = self.qs.(q_idx) in
|
||||
|
|
@ -69,13 +69,11 @@ let worker_thread_ ~on_exn (active : bool A.t) (qs : task Bb_queue.t array)
|
|||
|
||||
let task =
|
||||
try
|
||||
for _retry = 1 to 3 do
|
||||
for i = 0 to num_qs - 1 do
|
||||
let q = qs.((offset + i) mod num_qs) in
|
||||
match Bb_queue.try_pop ~force_lock:false q with
|
||||
| Some f -> raise_notrace (Got_task f)
|
||||
| None -> ()
|
||||
done
|
||||
for i = 0 to num_qs - 1 do
|
||||
let q = qs.((offset + i) mod num_qs) in
|
||||
match Bb_queue.try_pop ~force_lock:false q with
|
||||
| Some f -> raise_notrace (Got_task f)
|
||||
| None -> ()
|
||||
done;
|
||||
pop_blocking ()
|
||||
with Got_task f -> f
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue