From c520811e9175f554784e7bac9f0c27e61a1cc2f8 Mon Sep 17 00:00:00 2001 From: devil-ira Date: Sat, 6 Aug 2022 14:53:27 +0200 Subject: [PATCH] Address comments. --- .../src/schedule/executor_parallel.rs | 76 ++++++------------- crates/bevy_pbr/src/material.rs | 2 +- crates/bevy_winit/src/winit_windows.rs | 6 -- 3 files changed, 23 insertions(+), 61 deletions(-) diff --git a/crates/bevy_ecs/src/schedule/executor_parallel.rs b/crates/bevy_ecs/src/schedule/executor_parallel.rs index c60bb957e4299a..887501a1fc87ff 100644 --- a/crates/bevy_ecs/src/schedule/executor_parallel.rs +++ b/crates/bevy_ecs/src/schedule/executor_parallel.rs @@ -325,16 +325,17 @@ mod scheduling_event { #[cfg(test)] #[cfg(test)] mod tests { - use super::scheduling_event::*; use crate::{ - schedule::{SingleThreadedExecutor, Stage, SystemStage}, - system::{NonSend, Query, Res, ResMut}, + self as bevy_ecs, + component::Component, + schedule::{ + executor_parallel::scheduling_event::*, SingleThreadedExecutor, Stage, SystemStage, + }, + system::{NonSend, Query, Res, ResMut, Resource}, world::World, }; - use crate as bevy_ecs; - use crate::component::Component; - use crate::system::Resource; + use SchedulingEvent::StartedSystems; #[derive(Component)] struct W(T); @@ -361,10 +362,7 @@ mod tests { stage.run(&mut world); assert_eq!( receive_events(&world), - vec![ - SchedulingEvent::StartedSystems(3), - SchedulingEvent::StartedSystems(3), - ] + vec![StartedSystems(3), StartedSystems(3),] ); } @@ -380,10 +378,7 @@ mod tests { stage.run(&mut world); assert_eq!( receive_events(&world), - vec![ - SchedulingEvent::StartedSystems(1), - SchedulingEvent::StartedSystems(1), - ] + vec![StartedSystems(1), StartedSystems(1),] ); let mut stage = SystemStage::parallel() .with_system(wants_mut) @@ -391,19 +386,13 @@ mod tests { stage.run(&mut world); assert_eq!( receive_events(&world), - vec![ - SchedulingEvent::StartedSystems(1), - SchedulingEvent::StartedSystems(1), - ] + vec![StartedSystems(1), StartedSystems(1),] ); let mut stage = SystemStage::parallel() .with_system(wants_ref) .with_system(wants_ref); stage.run(&mut world); - assert_eq!( - receive_events(&world), - vec![SchedulingEvent::StartedSystems(2),] - ); + assert_eq!(receive_events(&world), vec![StartedSystems(2),]); } #[test] @@ -418,10 +407,7 @@ mod tests { stage.run(&mut world); assert_eq!( receive_events(&world), - vec![ - SchedulingEvent::StartedSystems(1), - SchedulingEvent::StartedSystems(1), - ] + vec![StartedSystems(1), StartedSystems(1),] ); let mut stage = SystemStage::parallel() .with_system(wants_mut) @@ -429,19 +415,13 @@ mod tests { stage.run(&mut world); assert_eq!( receive_events(&world), - vec![ - SchedulingEvent::StartedSystems(1), - SchedulingEvent::StartedSystems(1), - ] + vec![StartedSystems(1), StartedSystems(1),] ); let mut stage = SystemStage::parallel() .with_system(wants_ref) .with_system(wants_ref); stage.run(&mut world); - assert_eq!( - receive_events(&world), - vec![SchedulingEvent::StartedSystems(2),] - ); + assert_eq!(receive_events(&world), vec![StartedSystems(2),]); let mut world = World::new(); world.spawn().insert_bundle((W(0usize), W(0u32), W(0f32))); fn wants_mut_usize(_: Query<(&mut W, &W)>) {} @@ -450,10 +430,7 @@ mod tests { .with_system(wants_mut_usize) .with_system(wants_mut_u32); stage.run(&mut world); - assert_eq!( - receive_events(&world), - vec![SchedulingEvent::StartedSystems(2),] - ); + assert_eq!(receive_events(&world), vec![StartedSystems(2),]); } #[test] @@ -468,10 +445,7 @@ mod tests { stage.run(&mut world); assert_eq!( receive_events(&world), - vec![ - SchedulingEvent::StartedSystems(1), - SchedulingEvent::StartedSystems(1), - ] + vec![StartedSystems(1), StartedSystems(1),] ); let mut stage = SystemStage::parallel() .with_system(wants_mut) @@ -479,19 +453,13 @@ mod tests { stage.run(&mut world); assert_eq!( receive_events(&world), - vec![ - SchedulingEvent::StartedSystems(1), - SchedulingEvent::StartedSystems(1), - ] + vec![StartedSystems(1), StartedSystems(1),] ); let mut stage = SystemStage::parallel() .with_system(wants_world) .with_system(wants_world); stage.run(&mut world); - assert_eq!( - receive_events(&world), - vec![SchedulingEvent::StartedSystems(2),] - ); + assert_eq!(receive_events(&world), vec![StartedSystems(2),]); } #[test] @@ -514,10 +482,10 @@ mod tests { assert_eq!( receive_events(&world), vec![ - SchedulingEvent::StartedSystems(3), - SchedulingEvent::StartedSystems(1), - SchedulingEvent::StartedSystems(1), - SchedulingEvent::StartedSystems(1), + StartedSystems(3), + StartedSystems(1), + StartedSystems(1), + StartedSystems(1), ] ); stage.set_executor(Box::new(SingleThreadedExecutor::default())); diff --git a/crates/bevy_pbr/src/material.rs b/crates/bevy_pbr/src/material.rs index 68cfa229823b8e..791dca0c34a367 100644 --- a/crates/bevy_pbr/src/material.rs +++ b/crates/bevy_pbr/src/material.rs @@ -453,7 +453,7 @@ impl Default for ExtractedMaterials { /// Stores all prepared representations of [`Material`] assets for as long as they exist. #[derive(Resource, Deref, DerefMut)] -pub struct RenderMaterials(HashMap, PreparedMaterial>); +pub struct RenderMaterials(pub HashMap, PreparedMaterial>); impl Default for RenderMaterials { fn default() -> Self { diff --git a/crates/bevy_winit/src/winit_windows.rs b/crates/bevy_winit/src/winit_windows.rs index 91550eeffecf70..4703bcdc7854f4 100644 --- a/crates/bevy_winit/src/winit_windows.rs +++ b/crates/bevy_winit/src/winit_windows.rs @@ -264,9 +264,3 @@ pub fn get_best_videomode(monitor: &winit::monitor::MonitorHandle) -> winit::mon modes.first().unwrap().clone() } - -// WARNING: this only works under the assumption that wasm runtime is single threaded -#[cfg(target_arch = "wasm32")] -unsafe impl Send for WinitWindows {} -#[cfg(target_arch = "wasm32")] -unsafe impl Sync for WinitWindows {}