Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SystemGraph as a handle-based method for explicitly creating system dependency graphs #2381

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b50be36
Add SystemSet::as_sequential
james7132 Jun 23, 2021
e8acce4
Update crates/bevy_ecs/src/schedule/system_set.rs
james7132 Jun 23, 2021
c312419
Fix formatting and use wrapping_add
james7132 Jun 23, 2021
8502a27
Add unit test
james7132 Jun 23, 2021
b7c3a48
Add SystemGraph implementation
james7132 Jun 24, 2021
3ba637f
Revert SystemSet::as_sequential
james7132 Jun 24, 2021
384f913
Remove extra space
james7132 Jun 24, 2021
14e403a
Review changes + doc comments
james7132 Jun 24, 2021
1415e90
Use Rc/RefCell instead of Arc/Mutex
james7132 Jun 24, 2021
a1e10d5
Support split_into as a utilty function for fan-out topologies
james7132 Jun 24, 2021
40aa658
Use separate graph and node counters
james7132 Jun 25, 2021
b0fc252
Add tuple implementations for SystemJoin
james7132 Jun 25, 2021
9f3eee1
Use IntoSystemDescriptor instead of Into<SystemDescriptor>
james7132 Jun 27, 2021
d4043cd
Use impl Into<SystemSet> instead of SystemSet to simply addition
james7132 Jun 27, 2021
02b8a3a
Add SystemGraph example
james7132 Jun 27, 2021
f8727a7
Use a more descriptive comment in SystemGraph example
james7132 Jun 27, 2021
a9c0cc9
Fixes for CI and review comments
james7132 Jun 27, 2021
204ff3e
Add tests for accurate labelling
james7132 Jun 27, 2021
bc58b6b
Systemyeet
james7132 Jul 2, 2021
3a7ebc9
Add par_join for easier explicit many-to-many dependencies
james7132 Jul 2, 2021
bafe1cb
Review fixes: Doc comments and naming
james7132 Jul 4, 2021
066bceb
Fix build/tests
james7132 Dec 23, 2021
913547c
Remove unused use statements
james7132 Dec 23, 2021
038703b
Fix docs CI
james7132 Feb 2, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,10 @@ path = "examples/ecs/state.rs"
name = "system_chaining"
path = "examples/ecs/system_chaining.rs"

[[example]]
name = "system_graph"
path = "examples/ecs/system_graph.rs"

[[example]]
name = "system_param"
path = "examples/ecs/system_param.rs"
Expand Down
6 changes: 3 additions & 3 deletions crates/bevy_app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ impl App {
/// .with_system(system_c),
/// );
/// ```
pub fn add_system_set(&mut self, system_set: SystemSet) -> &mut Self {
pub fn add_system_set(&mut self, system_set: impl Into<SystemSet>) -> &mut Self {
self.add_system_set_to_stage(CoreStage::Update, system_set)
}

Expand Down Expand Up @@ -381,7 +381,7 @@ impl App {
pub fn add_system_set_to_stage(
&mut self,
stage_label: impl StageLabel,
system_set: SystemSet,
system_set: impl Into<SystemSet>,
) -> &mut Self {
self.schedule
.add_system_set_to_stage(stage_label, system_set);
Expand Down Expand Up @@ -491,7 +491,7 @@ impl App {
pub fn add_startup_system_set_to_stage(
&mut self,
stage_label: impl StageLabel,
system_set: SystemSet,
system_set: impl Into<SystemSet>,
) -> &mut Self {
self.schedule
.stage(CoreStage::Startup, |schedule: &mut Schedule| {
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_ecs/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ impl Parse for AllTuples {
#[proc_macro]
pub fn all_tuples(input: TokenStream) -> TokenStream {
let input = parse_macro_input!(input as AllTuples);
let len = (input.start..=input.end).count();
let len = input.end + 1;
let mut ident_tuples = Vec::with_capacity(len);
for i in input.start..=input.end {
for i in 0..=input.end {
let idents = input
.idents
.iter()
Expand Down
3 changes: 2 additions & 1 deletion crates/bevy_ecs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ pub mod prelude {
schedule::{
AmbiguitySetLabel, ExclusiveSystemDescriptorCoercion, ParallelSystemDescriptorCoercion,
RunCriteria, RunCriteriaDescriptorCoercion, RunCriteriaLabel, RunCriteriaPiping,
Schedule, Stage, StageLabel, State, SystemLabel, SystemSet, SystemStage,
Schedule, Stage, StageLabel, State, SystemGraph, SystemGroup, SystemJoin, SystemLabel,
SystemSet, SystemStage,
},
system::{
Commands, ConfigurableSystem, In, IntoChainSystem, IntoExclusiveSystem, IntoSystem,
Expand Down
4 changes: 3 additions & 1 deletion crates/bevy_ecs/src/schedule/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mod stage;
mod state;
mod system_container;
mod system_descriptor;
mod system_graph;
mod system_set;

pub use executor::*;
Expand All @@ -23,6 +24,7 @@ pub use stage::*;
pub use state::*;
pub use system_container::*;
pub use system_descriptor::*;
pub use system_graph::*;
pub use system_set::*;

use std::fmt::Debug;
Expand Down Expand Up @@ -245,7 +247,7 @@ impl Schedule {
pub fn add_system_set_to_stage(
&mut self,
stage_label: impl StageLabel,
system_set: SystemSet,
system_set: impl Into<SystemSet>,
) -> &mut Self {
self.stage(stage_label, |stage: &mut SystemStage| {
stage.add_system_set(system_set)
Expand Down
5 changes: 3 additions & 2 deletions crates/bevy_ecs/src/schedule/stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,13 @@ impl SystemStage {
&self.exclusive_before_commands
}

pub fn with_system_set(mut self, system_set: SystemSet) -> Self {
pub fn with_system_set(mut self, system_set: impl Into<SystemSet>) -> Self {
self.add_system_set(system_set);
self
}

pub fn add_system_set(&mut self, system_set: SystemSet) -> &mut Self {
pub fn add_system_set(&mut self, system_set: impl Into<SystemSet>) -> &mut Self {
let system_set = system_set.into();
self.systems_modified = true;
let (run_criteria, mut systems) = system_set.bake();
let set_run_criteria_index = run_criteria.and_then(|criteria| {
Expand Down
Loading