Skip to content
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
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
7 changes: 7 additions & 0 deletions crates/bevy_ecs/src/schedule/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,13 @@ impl Schedule {
stage.run(world);
}
}

/// Iterates over all of schedule's stages and their labels, in execution order.
pub fn iter_stages(&self) -> impl Iterator<Item = (&dyn StageLabel, &dyn Stage)> {
self.stage_order
.iter()
.map(move |label| (&**label, &*self.stages[label]))
}
}

impl Stage for Schedule {
Expand Down
20 changes: 20 additions & 0 deletions crates/bevy_ecs/src/schedule/stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,26 @@ impl SystemStage {
self.add_system_to_set(system, 0)
}

/// Topologically sorted parallel systems.
///
/// Note that this method won't output fully-formed data until the stage has been ran at least once.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This applies to all systems.

pub fn parallel_systems(&self) -> &[impl SystemContainer] {
&self.parallel
}
/// Topologically sorted exclusive systems that want to be ran at the start of the stage.
pub fn exclusive_at_start_systems(&self) -> &[impl SystemContainer] {
&self.exclusive_at_start
}
/// Topologically sorted exclusive systems that want to be ran at the end of the stage.
pub fn exclusive_at_end_systems(&self) -> &[impl SystemContainer] {
&self.exclusive_at_end
}
/// Topologically sorted exclusive systems that want to be ran after parallel systems but
/// before the application of their command buffers.
Comment thread
jakobhellermann marked this conversation as resolved.
pub fn exclusive_before_commands_systems(&self) -> &[impl SystemContainer] {
&self.exclusive_before_commands
}

// TODO: consider exposing
fn add_system_to_set(&mut self, system: impl Into<SystemDescriptor>, set: usize) -> &mut Self {
self.systems_modified = true;
Expand Down
5 changes: 4 additions & 1 deletion crates/bevy_ecs/src/schedule/system_container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ use crate::{
};
use std::{borrow::Cow, ptr::NonNull};

pub(super) trait SystemContainer {
/// System metadata like its name, labels, order requirements and component access.
pub trait SystemContainer {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't intended to be exposed, but I suppose it won't be a problem, as long as there's no mutable access. Ideally, it should be documented as well.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only thing that's mutable is set_dependencies, but the dependencies are only used for ambiguity checking so exposing that at least isn't unsound.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add #[doc(hidden)] to some methods as well if we don't want to expose them.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.dependencies() is used for ordering, too. It would indeed be best annotate it and .set_dependencies() with #[doc(hidden)]: it's an implementation detail that just doesn't make sense to external users.

fn name(&self) -> Cow<'static, str>;
#[doc(hidden)]
fn dependencies(&self) -> &[usize];
#[doc(hidden)]
fn set_dependencies(&mut self, dependencies: impl IntoIterator<Item = usize>);
fn system_set(&self) -> usize;
fn labels(&self) -> &[BoxedSystemLabel];
Expand Down