Skip to content

Commit

Permalink
This commit fixes:
Browse files Browse the repository at this point in the history
- The change to downcast-rs was incomplete, errors were not caught in
release due to travis missing release build tests.
- Added release build tests
- Fixed a bug case where the scheduler would make a system dependent on
itself, causing the system to never run
  • Loading branch information
jaynus committed Nov 15, 2019
1 parent 2eab55d commit 3a9d2a3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ script:
- cargo test --no-default-features --features events
- cargo test --no-default-features --features par-iter
- cargo test --no-default-features --features ffi
- cargo test --release --all-features
- cargo test --release --no-default-features
- cargo test --release --no-default-features --features events
- cargo test --release --no-default-features --features par-iter
- cargo test --release --no-default-features --features ffi
15 changes: 0 additions & 15 deletions src/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ pub struct Fetch<'a, T: 'a + Resource> {
impl<'a, T: Resource> Deref for Fetch<'a, T> {
type Target = T;

#[cfg(debug_assertions)]
#[inline]
fn deref(&self) -> &Self::Target {
self.inner.downcast_ref::<T>().unwrap_or_else(|| {
Expand All @@ -132,10 +131,6 @@ impl<'a, T: Resource> Deref for Fetch<'a, T> {
)
})
}

#[cfg(not(debug_assertions))]
#[inline]
fn deref(&self) -> &Self::Target { unsafe { self.inner.downcast_ref_unchecked::<T>() } }
}

impl<'a, T: 'a + Resource + std::fmt::Debug> std::fmt::Debug for Fetch<'a, T> {
Expand All @@ -152,7 +147,6 @@ pub struct FetchMut<'a, T: Resource> {
impl<'a, T: 'a + Resource> Deref for FetchMut<'a, T> {
type Target = T;

#[cfg(debug_assertions)]
#[inline]
fn deref(&self) -> &Self::Target {
self.inner.downcast_ref::<T>().unwrap_or_else(|| {
Expand All @@ -162,14 +156,9 @@ impl<'a, T: 'a + Resource> Deref for FetchMut<'a, T> {
)
})
}

#[cfg(not(debug_assertions))]
#[inline]
fn deref(&self) -> &Self::Target { unsafe { self.inner.downcast_ref_unchecked::<T>() } }
}

impl<'a, T: 'a + Resource> DerefMut for FetchMut<'a, T> {
#[cfg(debug_assertions)]
#[inline]
fn deref_mut(&mut self) -> &mut T {
self.inner.downcast_mut::<T>().unwrap_or_else(|| {
Expand All @@ -179,10 +168,6 @@ impl<'a, T: 'a + Resource> DerefMut for FetchMut<'a, T> {
)
})
}

#[cfg(not(debug_assertions))]
#[inline]
fn deref_mut(&mut self) -> &mut T { unsafe { self.inner.downcast_mut_unchecked::<T>() } }
}

impl<'a, T: 'a + Resource + std::fmt::Debug> std::fmt::Debug for FetchMut<'a, T> {
Expand Down
11 changes: 7 additions & 4 deletions src/schedule.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl<'a> StageExecutor<'a> {
let mut component_mutated = HashMap::<ComponentTypeId, Vec<usize>>::with_capacity(64);

for (i, system) in systems.iter().enumerate() {
log::debug!("Building dependency: {}", system.name());
log::debug!("Building dependency: {} ({})", system.name(), i);

let (read_res, read_comp) = system.reads();
let (write_res, write_comp) = system.writes();
Expand Down Expand Up @@ -161,7 +161,9 @@ impl<'a> StageExecutor<'a> {
}
log::debug!("comp_dependencies: {:?}", &comp_dependencies);
for dep in comp_dependencies {
dynamic_dependants[dep].push(i);
if dep != i { // dont be dependent on ourselves
dynamic_dependants[dep].push(i);
}
}
}

Expand Down Expand Up @@ -243,6 +245,8 @@ impl<'a> StageExecutor<'a> {
)
.par_bridge()
.for_each(|(sys, static_dep, dyn_dep)| {
use std::any::Any;

let archetypes = sys.accesses_archetypes();
for i in (0..dyn_dep.len()).rev() {
let dep = dyn_dep[i];
Expand All @@ -269,7 +273,6 @@ impl<'a> StageExecutor<'a> {

// execute all systems with no outstanding dependencies
(0..systems.len())
.into_par_iter()
.filter(|i| awaiting[*i].load(Ordering::SeqCst) == 0)
.for_each(|i| {
self.run_recursive(i, world);
Expand All @@ -288,7 +291,7 @@ impl<'a> StageExecutor<'a> {
/// Recursively execute through the generated depedency cascade and exhaust it.
#[cfg(feature = "par-iter")]
fn run_recursive(&self, i: usize, world: &World) {
log::trace!("run_recursive: {}", i);
log::trace!("run_recursive: {} ({})", self.systems[i].name(), i);
self.systems[i].run(world);

self.static_dependants[i].par_iter().for_each(|dep| {
Expand Down

0 comments on commit 3a9d2a3

Please sign in to comment.