Skip to main content

adaptive_for_each_mut

Macro adaptive_for_each_mut 

Source
macro_rules! adaptive_for_each_mut {
    ($query:expr, |$item:pat_param| $body:expr $(,)?) => { ... };
    ($query:expr, $serial_threshold:expr, |$item:pat_param| $body:expr $(,)?) => { ... };
    ($query:expr $(,)?) => { ... };
}
Expand description

Iterates a mutable query serially when it contains at most a small number of items, and in parallel otherwise.

The default serial threshold is one item:

adaptive_for_each_mut!(query, |item| process(item));

An optional threshold keeps queries with at most that many items serial. Parallel iteration is used only when the query contains more items than the threshold:

adaptive_for_each_mut!(query, 4, |item| process(item));

The adapter inspects only enough read-only query items to choose a mode, then performs the mutable iteration.