
# 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>
2.0 KiB
2.0 KiB
title | pull_requests | ||
---|---|---|---|
Schedule API Cleanup |
|
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 aSystemKey
instead of a plainusize
NodeId::Set
: Now stores aSystemSetKey
instead of a plainusize
ScheduleBuildPass::collapse_set
: Now takes the type-specific keys. Wrap them back into aNodeId
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
: UseScheduleGraph::system_sets
andSystemSets::contains
.ScheduleGraph::get_set_at
: UseScheduleGraph::system_sets
andSystemSets::get
.ScheduleGraph::set_at
: UseScheduleGraph::system_sets
andSystemSets::index
(system_sets[key]
).ScheduleGraph::get_set_conditions_at
: UseScheduleGraph::system_sets
andSystemSets::get_conditions
.ScheduleGraph::system_sets
: UseScheduleGraph::system_sets
andSystemSets::iter
.ScheduleGraph::get_system_at
: UseScheduleGraph::systems
andSystems::get
.ScheduleGraph::system_at
: UseScheduleGraph::systems
andSystems::index
(systems[key]
).ScheduleGraph::systems
: UseScheduleGraph::systems
andSystems::iter
.
The following functions were removed:
NodeId::index
: You should match on and use theSystemKey
andSystemSetKey
instead.NodeId::cmp
: Use thePartialOrd
andOrd
traits instead.ScheduleGraph::set_conditions_at
: If needing to check presence of conditions, useScheduleGraph::system_sets
andSystemSets::has_conditions
. Otherwise, useSystemSets::get_conditions
.