File tree 1 file changed +8
-6
lines changed
1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -249,6 +249,8 @@ impl Machine {
249
249
continue ;
250
250
}
251
251
252
+ let mut sched = rt. sched . lock ( ) . unwrap ( ) ;
253
+
252
254
// One final check for available tasks while the scheduler is locked.
253
255
if let Some ( task) = iter:: repeat_with ( || self . find_task ( rt) )
254
256
. find ( |s| !s. is_retry ( ) )
@@ -258,19 +260,19 @@ impl Machine {
258
260
continue ;
259
261
}
260
262
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.
263
265
if sched. polling {
264
- thread:: sleep ( Duration :: from_micros ( 10 ) ) ;
265
- continue ;
266
+ break ;
266
267
}
267
268
269
+ // Unlock the schedule poll the reactor until new I/O events arrive.
268
270
sched. polling = true ;
269
271
drop ( sched) ;
270
-
271
272
rt. reactor . poll ( None ) . unwrap ( ) ;
272
273
273
- let mut sched = rt. sched . lock ( ) . unwrap ( ) ;
274
+ // Lock the scheduler again and re-register the machine.
275
+ sched = rt. sched . lock ( ) . unwrap ( ) ;
274
276
sched. polling = false ;
275
277
276
278
runs = 0 ;
You can’t perform that action at this time.
0 commit comments