-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Documentation mentionting chained .run_if(a).run_if(b) does not short-circuit, in contrast to run_if(a.and(b)) #21710
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
base: main
Are you sure you want to change the base?
Changes from all commits
6254ce5
3764352
943b59e
d4584af
4eb133a
12e5dc3
f628367
d8e9018
453d74e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -386,6 +386,14 @@ pub trait IntoScheduleConfigs<T: Schedulable<Metadata = GraphInfo, GroupMetadata | |
| /// Each individual condition will be evaluated at most once (per schedule run), | ||
| /// right before the corresponding system prepares to run. | ||
| /// | ||
| /// # Tick and Change Detection Behavior | ||
| /// | ||
| /// When using `distributive_run_if`: | ||
| /// - Each system evaluates the condition independently | ||
| /// - System ticks are updated individually based on when each system attempts to run | ||
| /// - Change detection remains accurate since each system maintains its own tick state | ||
| /// - In chained systems, later systems will still update their ticks even if earlier ones don't run | ||
| /// | ||
| /// This is equivalent to calling [`run_if`](IntoScheduleConfigs::run_if) on each individual | ||
| /// system, as shown below: | ||
| /// | ||
|
|
@@ -417,8 +425,11 @@ pub trait IntoScheduleConfigs<T: Schedulable<Metadata = GraphInfo, GroupMetadata | |
|
|
||
| /// Run the systems only if the [`SystemCondition`] is `true`. | ||
| /// | ||
| /// The `SystemCondition` will be evaluated at most once (per schedule run), | ||
| /// the first time a system in this set prepares to run. | ||
| /// Multiple conditions can be added in two ways: | ||
| /// - Chained calls like `.run_if(a).run_if(b)` evaluate all conditions independently | ||
| /// - Single call like `run_if(a.and(b))` short-circuits (`b` won't run if `a` is false) | ||
| /// | ||
| /// For per-system condition evaluation, use [`distributive_run_if`]. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The "Note" section below already mentions |
||
| /// | ||
| /// If this set contains more than one system, calling `run_if` is equivalent to adding each | ||
| /// system to a common set and configuring the run condition on that set, as shown below: | ||
|
|
@@ -549,6 +560,16 @@ impl<T: Schedulable<Metadata = GraphInfo, GroupMetadata = Chain>> IntoScheduleCo | |
| self | ||
| } | ||
|
|
||
| /// Chain systems to run in sequence, by implicitly adding ordering constraints between them. | ||
| /// | ||
| /// Systems in a chain: | ||
| /// - Execute in sequential order | ||
| /// - Each maintain their own tick state | ||
| /// - Have independent change detection | ||
| /// - Update ticks even when skipped by conditions | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this right? I thought systems only set their |
||
| /// - Equivalent to using `before` / `after` system orderings. | ||
| /// Later systems in the chain will see changes made by earlier systems while maintaining | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Somewhere in here, I think it would be helpful to explicitly call out that this is equivalent to adding before / after system orderings. |
||
| /// their own change detection state. | ||
| fn chain(self) -> Self { | ||
| self.chain_inner() | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're mentioning that each copy of the system keeps its own ticks, then it might also be worth mentioning that each one also keeps its own parameter state. Notably,
MessageReaderwill have a separate cursor for each one, so copies ofon_messagemay return different values.And similarly for the mentions of tick state and change detection in
fn chain().