moirai-iter 0.6.1

Parallel and async iterator combinators for Moirai concurrency library
Documentation

moirai-iter

crates.io docs.rs

Iterator combinators for the Moirai concurrency library. One iterator type abstracts over three execution contexts:

  • Parallel — CPU-bound work across worker threads with work stealing.
  • Async — I/O-bound work through async/await.
  • Hybrid — mixed workloads, the default for moirai_iter.

map and filter are synchronous adapters; collect, reduce, and for_each are async and must be awaited. Async-closure variants (map_async, filter_async, for_each_async) take a future-returning closure.

[dependencies]
moirai-iter = "0.5"
use moirai_iter::{moirai_iter, moirai_iter_parallel};

async fn example(data: Vec<u64>) {
    // Hybrid context.
    moirai_iter(data.clone())
        .map(|x| x * x)
        .filter(|&x| x > 10)
        .for_each(|x| println!("{x}"))
        .await;

    // Parallel context.
    let squares: Vec<u64> = moirai_iter_parallel(data).map(|x| x * x).collect().await;
    println!("{squares:?}");
}

Also exports the Rayon-style ParallelIterator / IndexedParallelIterator surface, par_range / async_range, and the ExecutionContext / ExecutionStrategy types.

Standalone nested workload

The bounded nested_stress example runs the nested parallel workload outside the libtest harness, which keeps the process shape available for diagnostics:

cargo run --locked --release -p moirai-iter --example nested_stress -- 300

The argument is the pass count (default 300, maximum 20,000). Each pass checks all 1,025 outer results against the 1,025-element inner reduction.

Full documentation: https://docs.rs/moirai-iter

License

Licensed under either of Apache-2.0 or MIT at your option.