File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -190,11 +190,13 @@ impl Driver {
190190        assert ! ( !handle. is_shutdown( ) ) ; 
191191
192192        // Finds out the min expiration time to park. 
193-         let  expiration_time = ( 0 ..rt_handle. time ( ) . inner . get_shard_size ( ) ) 
194-             . filter_map ( |id| { 
195-                 let  lock = rt_handle. time ( ) . inner . lock_sharded_wheel ( id) ; 
196-                 lock. next_expiration_time ( ) 
197-             } ) 
193+         let  locks = ( 0 ..rt_handle. time ( ) . inner . get_shard_size ( ) ) 
194+             . map ( |id| rt_handle. time ( ) . inner . lock_sharded_wheel ( id) ) 
195+             . collect :: < Vec < _ > > ( ) ; 
196+ 
197+         let  expiration_time = locks
198+             . iter ( ) 
199+             . filter_map ( |lock| lock. next_expiration_time ( ) ) 
198200            . min ( ) ; 
199201
200202        rt_handle
@@ -203,6 +205,9 @@ impl Driver {
203205            . next_wake 
204206            . store ( next_wake_time ( expiration_time) ) ; 
205207
208+         // Safety: After updating the `next_wake`, we drop all the locks. 
209+         drop ( locks) ; 
210+ 
206211        match  expiration_time { 
207212            Some ( when)  => { 
208213                let  now = handle. time_source . now ( rt_handle. clock ( ) ) ; 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments