File tree 1 file changed +15
-8
lines changed 1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -699,16 +699,23 @@ impl Simulation {
699
699
700
700
// Start a task that will shutdown the simulation if the total_time is met.
701
701
if let Some ( total_time) = self . cfg . total_time {
702
- let t = self . shutdown_trigger . clone ( ) ;
703
- let l = self . shutdown_listener . clone ( ) ;
702
+ let shutdown = self . shutdown_trigger . clone ( ) ;
703
+ let listener = self . shutdown_listener . clone ( ) ;
704
704
705
705
self . tasks . spawn ( async move {
706
- if time:: timeout ( total_time, l) . await . is_err ( ) {
707
- log:: info!(
708
- "Simulation run for {}s. Shutting down." ,
709
- total_time. as_secs( )
710
- ) ;
711
- t. trigger ( )
706
+ select ! {
707
+ biased;
708
+ _ = listener. clone( ) => {
709
+ log:: debug!( "Timeout task exited on listener signal" ) ;
710
+ }
711
+
712
+ _ = time:: sleep( total_time) => {
713
+ log:: info!(
714
+ "Simulation run for {}s. Shutting down." ,
715
+ total_time. as_secs( )
716
+ ) ;
717
+ shutdown. trigger( )
718
+ }
712
719
}
713
720
} ) ;
714
721
}
You can’t perform that action at this time.
0 commit comments