Skip to content

Commit

Permalink
reorder init steps for tuple methods
Browse files Browse the repository at this point in the history
  • Loading branch information
maniwani committed Nov 15, 2022
1 parent e49e534 commit 3b72d84
Show file tree
Hide file tree
Showing 3 changed files with 203 additions and 221 deletions.
34 changes: 17 additions & 17 deletions crates/bevy_ecs/src/schedule_v3/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use bevy_utils::HashSet;
use crate::{
schedule_v3::{
condition::{BoxedCondition, Condition},
graph::{DependencyEdgeKind, DependencyInfo},
graph::{DependencyEdgeKind, GraphInfo},
set::{BoxedSystemSet, IntoSystemSet, SystemSet},
},
system::{BoxedSystem, IntoSystem, System},
Expand All @@ -12,21 +12,21 @@ use crate::{
/// A [`SystemSet`] with scheduling metadata.
pub struct SystemSetConfig {
pub(super) set: BoxedSystemSet,
pub(super) info: DependencyInfo,
pub(super) graph_info: GraphInfo,
pub(super) conditions: Vec<BoxedCondition>,
}

/// A [`System`] with scheduling metadata.
pub struct SystemConfig {
pub(super) system: BoxedSystem,
pub(super) info: DependencyInfo,
pub(super) graph_info: GraphInfo,
pub(super) conditions: Vec<BoxedCondition>,
}

pub(super) fn new_set_unchecked(set: BoxedSystemSet) -> SystemSetConfig {
SystemSetConfig {
set,
info: DependencyInfo {
graph_info: GraphInfo {
sets: HashSet::new(),
edges: HashSet::new(),
},
Expand All @@ -44,7 +44,7 @@ fn new_system(system: BoxedSystem) -> SystemConfig {
let sets = system.default_system_sets().into_iter().collect();
SystemConfig {
system,
info: DependencyInfo {
graph_info: GraphInfo {
sets,
edges: HashSet::new(),
},
Expand Down Expand Up @@ -153,20 +153,20 @@ impl IntoSystemSetConfig for SystemSetConfig {

fn in_set(mut self, set: impl SystemSet) -> Self {
assert!(!set.is_system_type(), "invalid use of system type set");
self.info.sets.insert(set.dyn_clone());
self.graph_info.sets.insert(set.dyn_clone());
self
}

fn before<M>(mut self, set: impl IntoSystemSet<M>) -> Self {
self.info.edges.insert((
self.graph_info.edges.insert((
DependencyEdgeKind::Before,
set.into_system_set().dyn_clone(),
));
self
}

fn after<M>(mut self, set: impl IntoSystemSet<M>) -> Self {
self.info
self.graph_info
.edges
.insert((DependencyEdgeKind::After, set.into_system_set().dyn_clone()));
self
Expand Down Expand Up @@ -279,20 +279,20 @@ impl IntoSystemConfig<()> for SystemConfig {

fn in_set(mut self, set: impl SystemSet) -> Self {
assert!(!set.is_system_type(), "invalid use of system type set");
self.info.sets.insert(set.dyn_clone());
self.graph_info.sets.insert(set.dyn_clone());
self
}

fn before<M>(mut self, set: impl IntoSystemSet<M>) -> Self {
self.info.edges.insert((
self.graph_info.edges.insert((
DependencyEdgeKind::Before,
set.into_system_set().dyn_clone(),
));
self
}

fn after<M>(mut self, set: impl IntoSystemSet<M>) -> Self {
self.info
self.graph_info
.edges
.insert((DependencyEdgeKind::After, set.into_system_set().dyn_clone()));
self
Expand Down Expand Up @@ -384,7 +384,7 @@ impl IntoSystemCollection<()> for SystemCollection {
fn in_set(mut self, set: impl SystemSet) -> Self {
assert!(!set.is_system_type(), "invalid use of system type set");
for config in self.inner.iter_mut() {
config.info.sets.insert(set.dyn_clone());
config.graph_info.sets.insert(set.dyn_clone());
}

self
Expand All @@ -394,7 +394,7 @@ impl IntoSystemCollection<()> for SystemCollection {
let set = set.into_system_set();
for config in self.inner.iter_mut() {
config
.info
.graph_info
.edges
.insert((DependencyEdgeKind::Before, set.dyn_clone()));
}
Expand All @@ -406,7 +406,7 @@ impl IntoSystemCollection<()> for SystemCollection {
let set = set.into_system_set();
for config in self.inner.iter_mut() {
config
.info
.graph_info
.edges
.insert((DependencyEdgeKind::After, set.dyn_clone()));
}
Expand Down Expand Up @@ -464,7 +464,7 @@ impl IntoSystemSetCollection for SystemSetCollection {
fn in_set(mut self, set: impl SystemSet) -> Self {
assert!(!set.is_system_type(), "invalid use of system type set");
for config in self.inner.iter_mut() {
config.info.sets.insert(set.dyn_clone());
config.graph_info.sets.insert(set.dyn_clone());
}

self
Expand All @@ -474,7 +474,7 @@ impl IntoSystemSetCollection for SystemSetCollection {
let set = set.into_system_set();
for config in self.inner.iter_mut() {
config
.info
.graph_info
.edges
.insert((DependencyEdgeKind::Before, set.dyn_clone()));
}
Expand All @@ -486,7 +486,7 @@ impl IntoSystemSetCollection for SystemSetCollection {
let set = set.into_system_set();
for config in self.inner.iter_mut() {
config
.info
.graph_info
.edges
.insert((DependencyEdgeKind::After, set.dyn_clone()));
}
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ecs/src/schedule_v3/graph/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ pub(crate) enum DependencyEdgeKind {
}

#[derive(Clone)]
pub(crate) struct DependencyInfo {
pub(crate) struct GraphInfo {
pub(crate) sets: HashSet<BoxedSystemSet>,
pub(crate) edges: HashSet<(DependencyEdgeKind, BoxedSystemSet)>,
}

#[derive(Clone)]
pub(crate) struct IndexedDependencyInfo {
pub(crate) struct IndexedGraphInfo {
pub(crate) sets: HashSet<NodeId>,
pub(crate) edges: HashSet<(DependencyEdgeKind, NodeId)>,
}
Expand Down
Loading

0 comments on commit 3b72d84

Please sign in to comment.