1
- use std:: panic:: AssertUnwindSafe ;
2
-
3
1
use bevy_tasks:: { ComputeTaskPool , Scope , TaskPool , ThreadExecutor } ;
4
2
use bevy_utils:: default;
5
3
use bevy_utils:: syncunsafecell:: SyncUnsafeCell ;
@@ -177,10 +175,11 @@ impl SystemExecutor for MultiThreadedExecutor {
177
175
178
176
if self . num_running_systems > 0 {
179
177
// 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) ) ;
184
183
185
184
self . finish_system_and_signal_dependents ( index) ;
186
185
@@ -430,22 +429,14 @@ impl MultiThreadedExecutor {
430
429
let task = async move {
431
430
#[ cfg( feature = "trace" ) ]
432
431
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) } ;
437
434
#[ cfg( feature = "trace" ) ]
438
435
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) ) ;
449
440
} ;
450
441
451
442
#[ cfg( feature = "trace" ) ]
@@ -488,21 +479,13 @@ impl MultiThreadedExecutor {
488
479
let task = async move {
489
480
#[ cfg( feature = "trace" ) ]
490
481
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) ;
494
483
#[ cfg( feature = "trace" ) ]
495
484
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) ) ;
506
489
} ;
507
490
508
491
#[ cfg( feature = "trace" ) ]
@@ -512,21 +495,13 @@ impl MultiThreadedExecutor {
512
495
let task = async move {
513
496
#[ cfg( feature = "trace" ) ]
514
497
let system_guard = system_span. enter ( ) ;
515
- let res = std:: panic:: catch_unwind ( AssertUnwindSafe ( || {
516
- system. run ( ( ) , world) ;
517
- } ) ) ;
498
+ system. run ( ( ) , world) ;
518
499
#[ cfg( feature = "trace" ) ]
519
500
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) ) ;
530
505
} ;
531
506
532
507
#[ cfg( feature = "trace" ) ]
0 commit comments