Skip to content

Commit 466d133

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

File tree

1 file changed

+21
-46
lines changed

1 file changed

+21
-46
lines changed

crates/bevy_ecs/src/schedule/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::sync::Arc;
2-
31
use bevy_tasks::{ComputeTaskPool, Scope, TaskPool, ThreadExecutor};
42
use bevy_utils::default;
53
use bevy_utils::syncunsafecell::SyncUnsafeCell;
@@ -186,10 +184,11 @@ impl SystemExecutor for MultiThreadedExecutor {
186184

187185
if self.num_running_systems > 0 {
188186
// wait for systems to complete
189-
let index =
190-
self.receiver.recv().await.expect(
191-
"A system has panicked so the executor cannot continue.",
192-
);
187+
let index = self
188+
.receiver
189+
.recv()
190+
.await
191+
.unwrap_or_else(|error| unreachable!("{}", error));
193192

194193
self.finish_system_and_signal_dependents(index);
195194

@@ -439,22 +438,14 @@ impl MultiThreadedExecutor {
439438
let task = async move {
440439
#[cfg(feature = "trace")]
441440
let system_guard = system_span.enter();
442-
let res = std::panic::catch_unwind(AssertUnwindSafe(|| {
443-
// SAFETY: access is compatible
444-
unsafe { system.run_unsafe((), world) };
445-
}));
441+
// SAFETY: access is compatible
442+
unsafe { system.run_unsafe((), world) };
446443
#[cfg(feature = "trace")]
447444
drop(system_guard);
448-
if res.is_err() {
449-
// close the channel to propagate the error to the
450-
// multithreaded executor
451-
sender.close();
452-
} else {
453-
sender
454-
.send(system_index)
455-
.await
456-
.unwrap_or_else(|error| unreachable!("{}", error));
457-
}
445+
sender
446+
.send(system_index)
447+
.await
448+
.unwrap_or_else(|error| unreachable!("{}", error));
458449
};
459450

460451
#[cfg(feature = "trace")]
@@ -497,21 +488,13 @@ impl MultiThreadedExecutor {
497488
let task = async move {
498489
#[cfg(feature = "trace")]
499490
let system_guard = system_span.enter();
500-
let res = std::panic::catch_unwind(AssertUnwindSafe(|| {
501-
apply_system_buffers(&unapplied_systems, systems, world);
502-
}));
491+
apply_system_buffers(&unapplied_systems, systems, world);
503492
#[cfg(feature = "trace")]
504493
drop(system_guard);
505-
if res.is_err() {
506-
// close the channel to propagate the error to the
507-
// multithreaded executor
508-
sender.close();
509-
} else {
510-
sender
511-
.send(system_index)
512-
.await
513-
.unwrap_or_else(|error| unreachable!("{}", error));
514-
}
494+
sender
495+
.send(system_index)
496+
.await
497+
.unwrap_or_else(|error| unreachable!("{}", error));
515498
};
516499

517500
#[cfg(feature = "trace")]
@@ -521,21 +504,13 @@ impl MultiThreadedExecutor {
521504
let task = async move {
522505
#[cfg(feature = "trace")]
523506
let system_guard = system_span.enter();
524-
let res = std::panic::catch_unwind(AssertUnwindSafe(|| {
525-
system.run((), world);
526-
}));
507+
system.run((), world);
527508
#[cfg(feature = "trace")]
528509
drop(system_guard);
529-
if res.is_err() {
530-
// close the channel to propagate the error to the
531-
// multithreaded executor
532-
sender.close();
533-
} else {
534-
sender
535-
.send(system_index)
536-
.await
537-
.unwrap_or_else(|error| unreachable!("{}", error));
538-
}
510+
sender
511+
.send(system_index)
512+
.await
513+
.unwrap_or_else(|error| unreachable!("{}", error));
539514
};
540515

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

0 commit comments

Comments
 (0)