File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -249,6 +249,8 @@ impl Machine {
249249 continue ;
250250 }
251251
252+ let mut sched = rt. sched . lock ( ) . unwrap ( ) ;
253+
252254 // One final check for available tasks while the scheduler is locked.
253255 if let Some ( task) = iter:: repeat_with ( || self . find_task ( rt) )
254256 . find ( |s| !s. is_retry ( ) )
@@ -258,19 +260,19 @@ impl Machine {
258260 continue ;
259261 }
260262
261- let mut sched = rt . sched . lock ( ) . unwrap ( ) ;
262-
263+ // If another thread is already blocked on the reactor, there is no point in keeping
264+ // the current thread around since there is too little work to do.
263265 if sched. polling {
264- thread:: sleep ( Duration :: from_micros ( 10 ) ) ;
265- continue ;
266+ break ;
266267 }
267268
269+ // Unlock the schedule poll the reactor until new I/O events arrive.
268270 sched. polling = true ;
269271 drop ( sched) ;
270-
271272 rt. reactor . poll ( None ) . unwrap ( ) ;
272273
273- let mut sched = rt. sched . lock ( ) . unwrap ( ) ;
274+ // Lock the scheduler again and re-register the machine.
275+ sched = rt. sched . lock ( ) . unwrap ( ) ;
274276 sched. polling = false ;
275277
276278 runs = 0 ;
You can’t perform that action at this time.
0 commit comments