Skip to content

Commit

Permalink
fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
maniwani committed Nov 9, 2023
1 parent 5202c4e commit 8ea4c58
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 148 deletions.
4 changes: 1 addition & 3 deletions crates/bevy_app/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,6 @@ impl App {

// reassemble
*self = App::from_parts(sub_apps, tls, send, recv, runner);

self.remove_tls_channel();
}

/// Runs the [`App`] by calling its [runner](Self::set_runner).
Expand Down Expand Up @@ -930,7 +928,7 @@ fn run_once(mut app: App) {
// wait for plugins to finish setting up
let plugins_state = app.plugins_state();
if plugins_state != PluginsState::Cleaned {
while app.plugins_state() == PluginsState::Adding {
while app.plugins_state() != PluginsState::Ready {
#[cfg(not(target_arch = "wasm32"))]
bevy_tasks::tick_global_task_pools_on_main_thread();
}
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_app/src/schedule_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl Plugin for ScheduleRunnerPlugin {
// wait for plugins to finish setting up
let plugins_state = app.plugins_state();
if plugins_state != PluginsState::Cleaned {
while app.plugins_state() == PluginsState::Adding {
while app.plugins_state() != PluginsState::Ready {
#[cfg(not(target_arch = "wasm32"))]
bevy_tasks::tick_global_task_pools_on_main_thread();
}
Expand Down
4 changes: 0 additions & 4 deletions crates/bevy_ecs/macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,6 @@ pub fn impl_param_set(_input: TokenStream) -> TokenStream {
#param::init_state(world, &mut #meta);
let #param = #param::init_state(world, &mut system_meta.clone());
)*
// Make the ParamSet non-send if any of its parameters are non-send.
if false #(|| !#meta.is_send())* {
system_meta.set_non_send();
}
#(
system_meta
.component_access_set
Expand Down
9 changes: 9 additions & 0 deletions crates/bevy_ecs/src/storage/resource_non_send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,15 @@ impl ThreadLocalStorage {
TLS.with_borrow_mut(|tls| tls.resource_scope(f))
}

/// Runs `f` in a scope that has access to the thread-local resources.
pub fn run<F, T>(&mut self, f: F) -> T
where
F: FnOnce(&mut ThreadLocals) -> T,
T: 'static,
{
TLS.with_borrow_mut(|tls| f(tls))
}

/// Inserts a channel into `world` that systems in `world` (via [`ThreadLocal`]) can use to
/// access the underlying [`ThreadLocals`].
pub fn insert_channel<S>(&self, world: &mut World, sender: S)
Expand Down
30 changes: 0 additions & 30 deletions crates/bevy_ecs/src/system/system_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1506,34 +1506,4 @@ mod tests {
schedule.add_systems(non_sync_system);
schedule.run(&mut world);
}

// Regression test for https://github.com/bevyengine/bevy/issues/10207.
#[test]
fn param_set_non_send_first() {
fn non_send_param_set(mut p: ParamSet<(NonSend<*mut u8>, ())>) {
let _ = p.p0();
p.p1();
}

let mut world = World::new();
world.insert_non_send_resource(std::ptr::null_mut::<u8>());
let mut schedule = crate::schedule::Schedule::default();
schedule.add_systems((non_send_param_set, non_send_param_set, non_send_param_set));
schedule.run(&mut world);
}

// Regression test for https://github.com/bevyengine/bevy/issues/10207.
#[test]
fn param_set_non_send_second() {
fn non_send_param_set(mut p: ParamSet<((), NonSendMut<*mut u8>)>) {
p.p0();
let _ = p.p1();
}

let mut world = World::new();
world.insert_non_send_resource(std::ptr::null_mut::<u8>());
let mut schedule = crate::schedule::Schedule::default();
schedule.add_systems((non_send_param_set, non_send_param_set, non_send_param_set));
schedule.run(&mut world);
}
}
Loading

0 comments on commit 8ea4c58

Please sign in to comment.