Skip to content

Commit ac44159

Browse files
committed
Revert "Stageless: close the finish channel so executor doesn't deadlock (bevyengine#7448)"
This reverts commit ff7d5ff.
1 parent 3900b48 commit ac44159

File tree

1 file changed

+21
-46
lines changed

1 file changed

+21
-46
lines changed

crates/bevy_ecs/src/schedule_v3/executor/multi_threaded.rs

Lines changed: 21 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use std::panic::AssertUnwindSafe;
2-
31
use bevy_tasks::{ComputeTaskPool, Scope, TaskPool, ThreadExecutor};
42
use bevy_utils::default;
53
use bevy_utils::syncunsafecell::SyncUnsafeCell;
@@ -177,10 +175,11 @@ impl SystemExecutor for MultiThreadedExecutor {
177175

178176
if self.num_running_systems > 0 {
179177
// wait for systems to complete
180-
let index =
181-
self.receiver.recv().await.expect(
182-
"A system has panicked so the executor cannot continue.",
183-
);
178+
let index = self
179+
.receiver
180+
.recv()
181+
.await
182+
.unwrap_or_else(|error| unreachable!("{}", error));
184183

185184
self.finish_system_and_signal_dependents(index);
186185

@@ -430,22 +429,14 @@ impl MultiThreadedExecutor {
430429
let task = async move {
431430
#[cfg(feature = "trace")]
432431
let system_guard = system_span.enter();
433-
let res = std::panic::catch_unwind(AssertUnwindSafe(|| {
434-
// SAFETY: access is compatible
435-
unsafe { system.run_unsafe((), world) };
436-
}));
432+
// SAFETY: access is compatible
433+
unsafe { system.run_unsafe((), world) };
437434
#[cfg(feature = "trace")]
438435
drop(system_guard);
439-
if res.is_err() {
440-
// close the channel to propagate the error to the
441-
// multithreaded executor
442-
sender.close();
443-
} else {
444-
sender
445-
.send(system_index)
446-
.await
447-
.unwrap_or_else(|error| unreachable!("{}", error));
448-
}
436+
sender
437+
.send(system_index)
438+
.await
439+
.unwrap_or_else(|error| unreachable!("{}", error));
449440
};
450441

451442
#[cfg(feature = "trace")]
@@ -488,21 +479,13 @@ impl MultiThreadedExecutor {
488479
let task = async move {
489480
#[cfg(feature = "trace")]
490481
let system_guard = system_span.enter();
491-
let res = std::panic::catch_unwind(AssertUnwindSafe(|| {
492-
apply_system_buffers(&unapplied_systems, systems, world);
493-
}));
482+
apply_system_buffers(&unapplied_systems, systems, world);
494483
#[cfg(feature = "trace")]
495484
drop(system_guard);
496-
if res.is_err() {
497-
// close the channel to propagate the error to the
498-
// multithreaded executor
499-
sender.close();
500-
} else {
501-
sender
502-
.send(system_index)
503-
.await
504-
.unwrap_or_else(|error| unreachable!("{}", error));
505-
}
485+
sender
486+
.send(system_index)
487+
.await
488+
.unwrap_or_else(|error| unreachable!("{}", error));
506489
};
507490

508491
#[cfg(feature = "trace")]
@@ -512,21 +495,13 @@ impl MultiThreadedExecutor {
512495
let task = async move {
513496
#[cfg(feature = "trace")]
514497
let system_guard = system_span.enter();
515-
let res = std::panic::catch_unwind(AssertUnwindSafe(|| {
516-
system.run((), world);
517-
}));
498+
system.run((), world);
518499
#[cfg(feature = "trace")]
519500
drop(system_guard);
520-
if res.is_err() {
521-
// close the channel to propagate the error to the
522-
// multithreaded executor
523-
sender.close();
524-
} else {
525-
sender
526-
.send(system_index)
527-
.await
528-
.unwrap_or_else(|error| unreachable!("{}", error));
529-
}
501+
sender
502+
.send(system_index)
503+
.await
504+
.unwrap_or_else(|error| unreachable!("{}", error));
530505
};
531506

532507
#[cfg(feature = "trace")]

0 commit comments

Comments
 (0)