bevy/benches/benches/bevy_ecs
Joseph ddbfa48711
Simplify parallel iteration methods (#8854)
# Objective

The `QueryParIter::for_each_mut` function is required when doing
parallel iteration with mutable queries.
This results in an unfortunate stutter:
`query.par_iter_mut().par_for_each_mut()` ('mut' is repeated).

## Solution

- Make `for_each` compatible with mutable queries, and deprecate
`for_each_mut`. In order to prevent `for_each` from being called
multiple times in parallel, we take ownership of the QueryParIter.

---

## Changelog

- `QueryParIter::for_each` is now compatible with mutable queries.
`for_each_mut` has been deprecated as it is now redundant.

## Migration Guide

The method `QueryParIter::for_each_mut` has been deprecated and is no
longer functional. Use `for_each` instead, which now supports mutable
queries.

```rust
// Before:
query.par_iter_mut().for_each_mut(|x| ...);

// After:
query.par_iter_mut().for_each(|x| ...);
```

The method `QueryParIter::for_each` now takes ownership of the
`QueryParIter`, rather than taking a shared reference.

```rust
// Before:
let par_iter = my_query.par_iter().batching_strategy(my_batching_strategy);
par_iter.for_each(|x| {
    // ...Do stuff with x...
    par_iter.for_each(|y| {
        // ...Do nested stuff with y...
    });
});

// After:
my_query.par_iter().batching_strategy(my_batching_strategy).for_each(|x| {
    // ...Do stuff with x...
    my_query.par_iter().batching_strategy(my_batching_strategy).for_each(|y| {
        // ...Do nested stuff with y...
    });
});
```
2023-07-23 11:09:24 +00:00
..
components Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
events Require #[derive(Event)] on all Events (#7086) 2023-06-06 14:44:32 +00:00
iteration Simplify parallel iteration methods (#8854) 2023-07-23 11:09:24 +00:00
scheduling Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
world Migrate the rest of the engine to UnsafeWorldCell (#8833) 2023-06-15 01:31:56 +00:00
benches.rs Basic event benchmarks (#8251) 2023-03-31 07:12:18 +00:00
change_detection.rs Change Detection Benchmarks (#4972) 2022-11-04 17:53:54 +00:00
empty_archetypes.rs Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00