pub trait ForEachOrdered: IndexedParallelIterator {
// Required methods
fn for_each_ordered<F>(self, f: F)
where Self::Item: Send,
F: FnMut(Self::Item);
fn for_each_ordered_in<F>(self, pool: &ThreadPool, f: F)
where Self::Item: Send,
F: FnMut(Self::Item);
}rayon and tasks only.Expand description
Extension trait for [IndexedParallelIterator]
that streams results to a sequential consumer in index order.
Required Methods§
Sourcefn for_each_ordered<F>(self, f: F)
fn for_each_ordered<F>(self, f: F)
Executes the parallel iterator, calling f on each result sequentially in index
order.
Items are computed in parallel, but f is invoked as f(item_0), f(item_1), …,
f(item_{n-1}) on the calling thread. The calling thread receives each item as soon
as it (and all preceding items) are ready.
f does not need to be Send — it runs exclusively on the calling thread.
§Blocking
The calling thread blocks (via a condvar, or a scheduled channel under fuzz plus --cfg dst) while waiting for the next item to become ready. It does not participate in
rayon’s work-stealing while blocked. With the native backend, invoke this from a dedicated
blocking thread (e.g. via [tokio::task::spawn_blocking]) rather than the rayon thread
pool. With fuzz plus --cfg dst, invoke this inside
reth_concurrency::sync::Runtime::run or one of its selected threads, not directly from a
Tokio blocking worker.
Sourcefn for_each_ordered_in<F>(self, pool: &ThreadPool, f: F)
fn for_each_ordered_in<F>(self, pool: &ThreadPool, f: F)
Like for_each_ordered, but runs the parallel work on the
given pool instead of the global rayon thread pool.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".