File tree Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Expand file tree Collapse file tree 1 file changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -769,16 +769,23 @@ impl Simulation {
769
769
770
770
// Start a task that will shutdown the simulation if the total_time is met.
771
771
if let Some ( total_time) = self . cfg . total_time {
772
- let t = self . shutdown_trigger . clone ( ) ;
773
- let l = self . shutdown_listener . clone ( ) ;
772
+ let shutdown = self . shutdown_trigger . clone ( ) ;
773
+ let listener = self . shutdown_listener . clone ( ) ;
774
774
775
775
self . tasks . spawn ( async move {
776
- if time:: timeout ( total_time, l) . await . is_err ( ) {
777
- log:: info!(
778
- "Simulation run for {}s. Shutting down." ,
779
- total_time. as_secs( )
780
- ) ;
781
- t. trigger ( )
776
+ select ! {
777
+ biased;
778
+ _ = listener. clone( ) => {
779
+ log:: debug!( "Timeout task exited on listener signal" ) ;
780
+ }
781
+
782
+ _ = time:: sleep( total_time) => {
783
+ log:: info!(
784
+ "Simulation run for {}s. Shutting down." ,
785
+ total_time. as_secs( )
786
+ ) ;
787
+ shutdown. trigger( )
788
+ }
782
789
}
783
790
} ) ;
784
791
}
You can’t perform that action at this time.
0 commit comments