1
- use std:: sync:: Arc ;
2
-
3
1
use bevy_tasks:: { ComputeTaskPool , Scope , TaskPool , ThreadExecutor } ;
4
2
use bevy_utils:: default;
5
3
use bevy_utils:: syncunsafecell:: SyncUnsafeCell ;
@@ -186,10 +184,11 @@ impl SystemExecutor for MultiThreadedExecutor {
186
184
187
185
if self . num_running_systems > 0 {
188
186
// 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) ) ;
193
192
194
193
self . finish_system_and_signal_dependents ( index) ;
195
194
@@ -439,22 +438,14 @@ impl MultiThreadedExecutor {
439
438
let task = async move {
440
439
#[ cfg( feature = "trace" ) ]
441
440
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) } ;
446
443
#[ cfg( feature = "trace" ) ]
447
444
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) ) ;
458
449
} ;
459
450
460
451
#[ cfg( feature = "trace" ) ]
@@ -497,21 +488,13 @@ impl MultiThreadedExecutor {
497
488
let task = async move {
498
489
#[ cfg( feature = "trace" ) ]
499
490
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) ;
503
492
#[ cfg( feature = "trace" ) ]
504
493
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) ) ;
515
498
} ;
516
499
517
500
#[ cfg( feature = "trace" ) ]
@@ -521,21 +504,13 @@ impl MultiThreadedExecutor {
521
504
let task = async move {
522
505
#[ cfg( feature = "trace" ) ]
523
506
let system_guard = system_span. enter ( ) ;
524
- let res = std:: panic:: catch_unwind ( AssertUnwindSafe ( || {
525
- system. run ( ( ) , world) ;
526
- } ) ) ;
507
+ system. run ( ( ) , world) ;
527
508
#[ cfg( feature = "trace" ) ]
528
509
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) ) ;
539
514
} ;
540
515
541
516
#[ cfg( feature = "trace" ) ]
0 commit comments