bevy/crates/bevy_app/src
Edgar Geier 300b275edc
run_if for SystemConfigs via anonymous system sets (#7676)
# Objective

- Fixes #7659

## Solution

The idea of anonymous system sets or "implicit hidden organizational
sets" was briefly mentioned by @cart here:
https://github.com/bevyengine/bevy/pull/7634#issuecomment-1428619449.

- `Schedule::add_systems` creates an implicit, anonymous system set of
all systems in `SystemConfigs`.
- All dependencies and conditions from the `SystemConfigs` are now
applied to the implicit system set, instead of being applied to each
individual system. This should not change the behavior, AFAIU, because
`before`, `after`, `run_if` and `ambiguous_with` are transitive
properties from a set to its members.
- The newly added `AnonymousSystemSet` stores the names of its members
to provide better error messages.
- The names are stored in a reference counted slice, allowing fast
clones of the `AnonymousSystemSet`.
- However, only the pointer of the slice is used for hash and equality
operations
- This ensures that two `AnonymousSystemSet` are not equal, even if they
have the same members / member names.
- So two identical `add_systems` calls will produce two different
`AnonymousSystemSet`s.
  - Clones of the same `AnonymousSystemSet` will be equal.

## Drawbacks
If my assumptions are correct, the observed behavior should stay the
same. But the number of system sets in the `Schedule` will increase with
each `add_systems` call. If this has negative performance implications,
`add_systems` could be changed to only create the implicit system set if
necessary / when a run condition was added.

---------

Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2023-03-30 21:39:10 +00:00
..
app.rs run_if for SystemConfigs via anonymous system sets (#7676) 2023-03-30 21:39:10 +00:00
ci_testing.rs Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
lib.rs Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
main_schedule.rs Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
plugin_group.rs Unique plugin (#6411) 2022-10-31 16:12:19 +00:00
plugin.rs Mention uniqueness check in plugin name method docs (#7554) 2023-02-07 22:40:22 +00:00
schedule_runner.rs Rename schedule v3 to schedule (#7519) 2023-02-06 18:44:40 +00:00