moirai-parallel
Synchronous data-parallel primitives for the
Moirai runtime — the rayon-style
surface. This is the parallel domain (throughput over data), distinct from
the concurrent domain in moirai-async. Every operation is fully synchronous
(no async, no .await), so it is safe inside pure compute kernels without
async contagion, and operates on borrowed slices with in-place mutation.
Strategy is a zero-sized ExecutionPolicy type — Sequential, Parallel, or
Adaptive — chosen at compile time, so every call monomorphizes with no dynamic
dispatch. .par() / .par_mut() return Adaptive handles, which parallelize at
or above ADAPTIVE_PARALLEL_THRESHOLD and run sequentially below it.
[]
= "0.5"
use ;
let v: = .collect;
let sum = v.par.map_reduce; // auto-routes
let mut m = v.clone;
m.par_mut.for_each;
The *_with::<P> free functions pin the policy explicitly
(for_each_with::<Sequential>(&data, f)) for the rare case that needs forced
sequential or forced parallel execution.
These operations run on the same unified hybrid scheduler as async work
(moirai_executor::global), not a separate pool.
Melinoe-backed partition helpers refresh the Moirai bridge before pool
dispatch. A direct melinoe::sync::partition_* caller should invoke
moirai_executor::initialize() (or moirai::initialize()) during startup.
Full documentation: https://docs.rs/moirai-parallel
License
Licensed under either of Apache-2.0 or MIT at your option.