Skip to content

Commit e0bf431

Browse files
committed
Remove ExclusiveSystemParam::apply (#7489)
# Objective The trait method `SystemParam::apply` allows a `SystemParam` type to defer world mutations, which is internally used to apply `Commands` at the end of the stage. Any operations that require `&mut World` access must be deferred in this way, since parallel systems do not have exclusive access to the world. The `ExclusiveSystemParam` trait (added in #6083) has an `apply` method which serves the same purpose. However, deferring mutations in this way does not make sense for exclusive systems since they already have `&mut World` access: there is no need to wait until a hard sync point, as the system *is* a hard sync point. World mutations can and should be performed within the body of the system. ## Solution Remove the method. There were no implementations of this method in the engine. --- ## Changelog *Note for maintainers: this changelog makes more sense if it's placed above the one for #6919.* - Removed the method `ExclusiveSystemParamState::apply`. ## Migration Guide *Note for maintainers: this migration guide makes more sense if it's placed above the one for #6919.* The trait method `ExclusiveSystemParamState::apply` has been removed. If you have an exclusive system with buffers that must be applied, you should apply them within the body of the exclusive system.
1 parent 6506ea4 commit e0bf431

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

crates/bevy_ecs/src/system/exclusive_function_system.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,10 @@ where
132132
}
133133

134134
#[inline]
135-
fn apply_buffers(&mut self, world: &mut World) {
136-
let param_state = self.param_state.as_mut().expect(PARAM_MESSAGE);
137-
Param::apply(param_state, world);
135+
fn apply_buffers(&mut self, _world: &mut World) {
136+
// "pure" exclusive systems do not have any buffers to apply.
137+
// Systems made by piping a normal system with an exclusive system
138+
// might have buffers to apply, but this is handled by `PipeSystem`.
138139
}
139140

140141
#[inline]

crates/bevy_ecs/src/system/exclusive_system_param.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ pub trait ExclusiveSystemParam: Sized {
1212
type Item<'s>: ExclusiveSystemParam<State = Self::State>;
1313

1414
fn init(world: &mut World, system_meta: &mut SystemMeta) -> Self::State;
15-
#[inline]
16-
fn apply(_state: &mut Self::State, _world: &mut World) {}
1715

1816
fn get_param<'s>(state: &'s mut Self::State, system_meta: &SystemMeta) -> Self::Item<'s>;
1917
}
@@ -74,12 +72,6 @@ macro_rules! impl_exclusive_system_param_tuple {
7472
(($($param::init(_world, _system_meta),)*))
7573
}
7674

77-
#[inline]
78-
fn apply(state: &mut Self::State, _world: &mut World) {
79-
let ($($param,)*) = state;
80-
$($param::apply($param, _world);)*
81-
}
82-
8375
#[inline]
8476
#[allow(clippy::unused_unit)]
8577
fn get_param<'s>(

0 commit comments

Comments
 (0)