pub trait TaskSizeExt: IndexedParallelIterator {
// Provided methods
fn with_min_task<T>(self) -> impl IndexedParallelIterator<Item = Self::Item>
where Self: Sized { ... }
fn with_min_task_bytes(
self,
item_bytes: usize,
) -> impl IndexedParallelIterator<Item = Self::Item>
where Self: Sized { ... }
fn for_each_min_task_bytes<F>(self, item_bytes: usize, op: F)
where Self: Sized,
F: Fn(Self::Item) + Send + Sync { ... }
fn map_collect_min_task_bytes<B, F>(
self,
item_bytes: usize,
map_op: F,
) -> Vec<B>
where Self: Sized,
B: Send,
F: Fn(Self::Item) -> B + Send + Sync { ... }
}Expand description
Task-size adapters for parallel iterators.
An adapter reads the loop’s own length and floors the split from the cost model. A call site then states what one item costs, instead of hardcoding a task count.
Provided Methods§
Sourcefn with_min_task<T>(self) -> impl IndexedParallelIterator<Item = Self::Item>where
Self: Sized,
fn with_min_task<T>(self) -> impl IndexedParallelIterator<Item = Self::Item>where
Self: Sized,
Floors the split for a loop whose item is a single element of the named type.
A body moving several elements per item charges for all of them.
Such a body asks through the byte-counted adapter instead.
Sourcefn with_min_task_bytes(
self,
item_bytes: usize,
) -> impl IndexedParallelIterator<Item = Self::Item>where
Self: Sized,
fn with_min_task_bytes(
self,
item_bytes: usize,
) -> impl IndexedParallelIterator<Item = Self::Item>where
Self: Sized,
Floors the split for a loop whose item moves a given number of bytes.
The count sums every element one item reads and every element it writes.
Use this when the width is known only at run time, such as a chunk of a matrix row.
Sourcefn for_each_min_task_bytes<F>(self, item_bytes: usize, op: F)
fn for_each_min_task_bytes<F>(self, item_bytes: usize, op: F)
Runs a body over every item, with the split floored by the cost model.
The count sums every element one item reads and every element it writes.
A loop the floor keeps whole is driven as a plain serial iterator, not as one task. rayon reaches a body through its own bridge, which costs about 1 ns per item.
Sourcefn map_collect_min_task_bytes<B, F>(
self,
item_bytes: usize,
map_op: F,
) -> Vec<B>
fn map_collect_min_task_bytes<B, F>( self, item_bytes: usize, map_op: F, ) -> Vec<B>
Maps every item and collects the results, with the split floored by the cost model.
The count sums every element one item reads and every element it writes.
A loop the floor keeps whole is collected serially, not through rayon’s collect folder.
That folder costs about 1 ns per item more than Extend, which a cheap body feels.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".