
# Objective - Part of #20115 We want to encapsulate each part of `ScheduleGraph` into its own specific struct to make parts of it easier to reuse and maintain. ## Solution - Pulled `ScheduleGraph::systems` and `ScheduleGraph::system_conditions` into a `Systems` struct and added a field for this new struct to `ScheduleGraph` - Broke up `ScheduleGraph::uninit` into `Systems::uninit` and `SystemSets::uninit` to eliminate `ScheduleGraph`'s direct field access of these types - Removed node and condition accessors from `ScheduleGraph`; the same operations are now available on `Systems` and `SystemSets` instead (accessible via their `pub` fields on `ScheduleGraph`) - Moved `Systems`, `SystemSets`, `SystemNode`, `SystemWithAccess`, and `ConditionWithAccess` into a separate file. ## Testing Added two new tests covering the API surface of `Systems` and `SystemSets`, respectively. --------- Co-authored-by: Chris Russell <8494645+chescock@users.noreply.github.com>
38 lines
2.0 KiB
Markdown
38 lines
2.0 KiB
Markdown
---
|
|
title: Schedule API Cleanup
|
|
pull_requests: [19352, 20119]
|
|
---
|
|
|
|
In order to support removing systems from schedules, `Vec`s storing `System`s and
|
|
`SystemSet`s have been replaced with `SlotMap`s which allow safely removing nodes and
|
|
reusing indices. The maps are respectively keyed by `SystemKey`s and `SystemSetKey`s.
|
|
|
|
The following signatures were changed:
|
|
|
|
- `NodeId::System`: Now stores a `SystemKey` instead of a plain `usize`
|
|
- `NodeId::Set`: Now stores a `SystemSetKey` instead of a plain `usize`
|
|
- `ScheduleBuildPass::collapse_set`: Now takes the type-specific keys. Wrap them back into a `NodeId` if necessary.
|
|
- The following functions now return the type-specific keys. Wrap them back into a `NodeId` if necessary.
|
|
- `Schedule::systems`
|
|
- `ScheduleGraph::conflicting_systems`
|
|
|
|
The following functions were replaced. Those that took or returned `NodeId` now
|
|
take or return `SystemKey` or `SystemSetKey`. Wrap/unwrap them as necessary.
|
|
|
|
- `ScheduleGraph::contains_set`: Use `ScheduleGraph::system_sets` and `SystemSets::contains`.
|
|
- `ScheduleGraph::get_set_at`: Use `ScheduleGraph::system_sets` and `SystemSets::get`.
|
|
- `ScheduleGraph::set_at`: Use `ScheduleGraph::system_sets` and `SystemSets::index` (`system_sets[key]`).
|
|
- `ScheduleGraph::get_set_conditions_at`: Use `ScheduleGraph::system_sets` and `SystemSets::get_conditions`.
|
|
- `ScheduleGraph::system_sets`: Use `ScheduleGraph::system_sets` and `SystemSets::iter`.
|
|
- `ScheduleGraph::get_system_at`: Use `ScheduleGraph::systems` and `Systems::get`.
|
|
- `ScheduleGraph::system_at`: Use `ScheduleGraph::systems` and `Systems::index` (`systems[key]`).
|
|
- `ScheduleGraph::systems`: Use `ScheduleGraph::systems` and `Systems::iter`.
|
|
|
|
The following functions were removed:
|
|
|
|
- `NodeId::index`: You should match on and use the `SystemKey` and `SystemSetKey` instead.
|
|
- `NodeId::cmp`: Use the `PartialOrd` and `Ord` traits instead.
|
|
- `ScheduleGraph::set_conditions_at`: If needing to check presence of conditions,
|
|
use `ScheduleGraph::system_sets` and `SystemSets::has_conditions`.
|
|
Otherwise, use `SystemSets::get_conditions`.
|