Moonpool_forkjoin
Fork-join primitives.
NOTE These are only available on OCaml 5.0 and above.
both f g
runs f()
and g()
, potentially in parallel, and returns their result when both are done. If any of f()
and g()
fails, then the whole computation fails.
This must be run from within the pool: for example, inside Pool.run
or inside a Fut.spawn
computation. This is because it relies on an effect handler to be installed.
NOTE this is only available on OCaml 5.
Same as both f g |> ignore
.
NOTE this is only available on OCaml 5.
for_ n f
is the parallel version of for i=0 to n-1 do f i done
.
f
is called with parameters low
and high
and must use them like so:
for j = low to high do (* … actual work *) done
. If chunk_size=1
then low=high
and the loop is not actually needed.
NOTE this is only available on OCaml 5.
all_array fs
runs all functions in fs
in tasks, and waits for all the results.
NOTE this is only available on OCaml 5.
all_list fs
runs all functions in fs
in tasks, and waits for all the results.
NOTE this is only available on OCaml 5.
all_init n f
runs functions f 0
, f 1
, … f (n-1)
in tasks, and waits for all the results.
NOTE this is only available on OCaml 5.
map_array f arr
is like Array.map f arr
, but runs in parallel.
NOTE this is only available on OCaml 5.