Skip to content

Commit

Permalink
change exclusive systems too
Browse files Browse the repository at this point in the history
  • Loading branch information
hymm committed Jan 31, 2023
1 parent a481e57 commit feeae40
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions crates/bevy_ecs/src/scheduling/executor/multi_threaded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ impl SystemExecutor for MultiThreadedExecutor {
.receiver
.recv()
.await
.expect("a system has panicked and closed the channel");
.expect("A system has panicked so the executor cannot continue.");

self.finish_system_and_signal_dependents(index);

Expand Down Expand Up @@ -492,13 +492,21 @@ impl MultiThreadedExecutor {
let task = async move {
#[cfg(feature = "trace")]
let system_guard = system_span.enter();
apply_system_buffers(&mut unapplied_systems, systems, world);
let res = std::panic::catch_unwind(AssertUnwindSafe(|| {
apply_system_buffers(&mut unapplied_systems, systems, world);
}));
#[cfg(feature = "trace")]
drop(system_guard);
sender
.send(system_index)
.await
.unwrap_or_else(|error| unreachable!("{}", error));
if res.is_err() {
// close the channel to propagate the error to the
// multithreaded executor
sender.close();
} else {
sender
.send(system_index)
.await
.unwrap_or_else(|error| unreachable!("{}", error));
}
};

#[cfg(feature = "trace")]
Expand All @@ -508,13 +516,21 @@ impl MultiThreadedExecutor {
let task = async move {
#[cfg(feature = "trace")]
let system_guard = system_span.enter();
system.run((), world);
let res = std::panic::catch_unwind(AssertUnwindSafe(|| {
system.run((), world);
}));
#[cfg(feature = "trace")]
drop(system_guard);
sender
.send(system_index)
.await
.unwrap_or_else(|error| unreachable!("{}", error));
if res.is_err() {
// close the channel to propagate the error to the
// multithreaded executor
sender.close();
} else {
sender
.send(system_index)
.await
.unwrap_or_else(|error| unreachable!("{}", error));
}
};

#[cfg(feature = "trace")]
Expand Down

0 comments on commit feeae40

Please sign in to comment.