Trait ParallelBridgeBuffered
pub trait ParallelBridgeBuffered: Sized + Iterator{
// Provided method
fn par_bridge_buffered(self) -> IntoIter<Self::Item> { ... }
}Expand description
Extension trait for iterators to convert them to parallel iterators via collection.
This is an alternative to [rayon::iter::ParallelBridge] that first collects the iterator
into a Vec, then calls [IntoParallelIterator] on it. This avoids the mutex contention
that can occur with par_bridge when either the iterator’s next() method is fast or the
parallel tasks are fast, as par_bridge wraps the iterator in a mutex.
§When to use
Use par_bridge_buffered instead of par_bridge when:
- The iterator produces items quickly
- The parallel work per item is relatively light
- The total number of items is known to be reasonable for memory
Stick with par_bridge when:
- The iterator is slow (e.g., I/O bound) and you want to overlap iteration with processing
- Memory is constrained and you cannot afford to collect all items upfront
Provided Methods§
fn par_bridge_buffered(self) -> IntoIter<Self::Item>
fn par_bridge_buffered(self) -> IntoIter<Self::Item>
Collects this iterator into a Vec and returns a parallel iterator over it.
See this trait’s documentation for more details.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".