Skip to content

Commit 3ff68b6

Browse files
hymmcart
andcommitted
Stageless: fix unapplied systems (#7446)
# Objective - The stageless executor keeps track of systems that have run, but have not applied their system buffers. The bitset for that was being cloned into apply_system_buffers and cleared in that function, but we need to clear the original version instead of the cloned version ## Solution - move the clear out of the apply_system_buffers function. Co-authored-by: Carter Anderson <mcanders1@gmail.com>
1 parent 9481a2c commit 3ff68b6

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

crates/bevy_ecs/src/schedule_v3/executor/multi_threaded.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,12 @@ impl SystemExecutor for MultiThreadedExecutor {
181181

182182
// SAFETY: all systems have completed
183183
let world = unsafe { &mut *world.get() };
184-
apply_system_buffers(&mut self.unapplied_systems, systems, world);
184+
apply_system_buffers(&self.unapplied_systems, systems, world);
185+
self.unapplied_systems.clear();
186+
debug_assert!(self.unapplied_systems.is_clear());
185187

186188
debug_assert!(self.ready_systems.is_clear());
187189
debug_assert!(self.running_systems.is_clear());
188-
debug_assert!(self.unapplied_systems.is_clear());
189190
self.active_access.clear();
190191
self.evaluated_sets.clear();
191192
self.skipped_systems.clear();
@@ -459,11 +460,12 @@ impl MultiThreadedExecutor {
459460
let sender = self.sender.clone();
460461
if is_apply_system_buffers(system) {
461462
// TODO: avoid allocation
462-
let mut unapplied_systems = self.unapplied_systems.clone();
463+
let unapplied_systems = self.unapplied_systems.clone();
464+
self.unapplied_systems.clear();
463465
let task = async move {
464466
#[cfg(feature = "trace")]
465467
let system_guard = system_span.enter();
466-
apply_system_buffers(&mut unapplied_systems, systems, world);
468+
apply_system_buffers(&unapplied_systems, systems, world);
467469
#[cfg(feature = "trace")]
468470
drop(system_guard);
469471
sender
@@ -545,7 +547,7 @@ impl MultiThreadedExecutor {
545547
}
546548

547549
fn apply_system_buffers(
548-
unapplied_systems: &mut FixedBitSet,
550+
unapplied_systems: &FixedBitSet,
549551
systems: &[SyncUnsafeCell<BoxedSystem>],
550552
world: &mut World,
551553
) {
@@ -556,8 +558,6 @@ fn apply_system_buffers(
556558
let _apply_buffers_span = info_span!("apply_buffers", name = &*system.name()).entered();
557559
system.apply_buffers(world);
558560
}
559-
560-
unapplied_systems.clear();
561561
}
562562

563563
fn evaluate_and_fold_conditions(conditions: &mut [BoxedCondition], world: &World) -> bool {

0 commit comments

Comments
 (0)