Skip to content

Commit

Permalink
Address comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-blackbird committed Aug 6, 2022
1 parent cc47e7b commit c520811
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 61 deletions.
76 changes: 22 additions & 54 deletions crates/bevy_ecs/src/schedule/executor_parallel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>(T);
Expand All @@ -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),]
);
}

Expand All @@ -380,30 +378,21 @@ 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)
.with_system(wants_ref);
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]
Expand All @@ -418,30 +407,21 @@ 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)
.with_system(wants_ref);
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<usize>, &W<f32>)>) {}
Expand All @@ -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]
Expand All @@ -468,30 +445,21 @@ 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)
.with_system(wants_world);
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]
Expand All @@ -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()));
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_pbr/src/material.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ impl<M: Material> Default for ExtractedMaterials<M> {

/// Stores all prepared representations of [`Material`] assets for as long as they exist.
#[derive(Resource, Deref, DerefMut)]
pub struct RenderMaterials<T: Material>(HashMap<Handle<T>, PreparedMaterial<T>>);
pub struct RenderMaterials<T: Material>(pub HashMap<Handle<T>, PreparedMaterial<T>>);

impl<T: Material> Default for RenderMaterials<T> {
fn default() -> Self {
Expand Down
6 changes: 0 additions & 6 deletions crates/bevy_winit/src/winit_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}

0 comments on commit c520811

Please sign in to comment.