mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-06 03:05:30 -05:00
fix: Fork_join.for_ 0 must not hang
This commit is contained in:
parent
e6a2afb2ba
commit
20240a6190
2 changed files with 46 additions and 40 deletions
|
|
@ -92,6 +92,7 @@ let both f g : _ * _ =
|
|||
let both_ignore f g = ignore (both f g : _ * _)
|
||||
|
||||
let for_ ?chunk_size n (f : int -> int -> unit) : unit =
|
||||
if n > 0 then (
|
||||
let has_failed = A.make false in
|
||||
let missing = A.make n in
|
||||
|
||||
|
|
@ -136,8 +137,8 @@ let for_ ?chunk_size n (f : int -> int -> unit) : unit =
|
|||
(fun ~run suspension ->
|
||||
(* run tasks, then we'll resume [suspension] *)
|
||||
start_tasks ~run suspension);
|
||||
};
|
||||
()
|
||||
}
|
||||
)
|
||||
|
||||
let all_array ?chunk_size (fs : _ array) : _ array =
|
||||
let len = Array.length fs in
|
||||
|
|
|
|||
|
|
@ -42,6 +42,11 @@ let () =
|
|||
let exp_sum = List.init 42 (fun x -> x * x) |> List.fold_left ( + ) 0 in
|
||||
assert (par_sum = exp_sum)
|
||||
|
||||
let () =
|
||||
Pool.run_wait_block pool (fun () ->
|
||||
Fork_join.for_ 0 (fun _ _ -> assert false));
|
||||
()
|
||||
|
||||
let () =
|
||||
let total_sum = Atomic.make 0 in
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue