@@ -322,26 +322,28 @@ impl<'s> Scheduler<'s> {
322322
323323 fn check_ready ( & mut self ) -> std:: io:: Result < ( ) > {
324324 // Check if the elements in the suspend queue are ready
325- if let Some ( item) = self . suspend . peek ( ) {
326- if now ( ) >= item. timestamp {
327- if let Some ( item) = self . suspend . pop ( ) {
328- item. coroutine . ready ( ) ?;
329- self . ready . push ( item. coroutine ) ;
330- }
325+ while let Some ( item) = self . suspend . peek ( ) {
326+ if now ( ) < item. timestamp {
327+ break ;
328+ }
329+ if let Some ( item) = self . suspend . pop ( ) {
330+ item. coroutine . ready ( ) ?;
331+ self . ready . push ( item. coroutine ) ;
331332 }
332333 }
333334 // Check if the elements in the syscall suspend queue are ready
334- if let Some ( item) = self . syscall_suspend . peek ( ) {
335- if now ( ) >= item. timestamp {
336- if let Some ( item ) = self . syscall_suspend . pop ( ) {
337- if let Some ( ( _ , co ) ) = self . syscall . remove ( item . co_name ) {
338- match co . state ( ) {
339- CoroutineState :: SystemCall ( val , syscall , SyscallState :: Suspend ( _ ) ) => {
340- co. syscall ( val , syscall , SyscallState :: Timeout ) ? ;
341- self . ready . push ( co ) ;
342- }
343- _ => unreachable ! ( "check_ready should never execute to here" ) ,
335+ while let Some ( item) = self . syscall_suspend . peek ( ) {
336+ if now ( ) < item. timestamp {
337+ break ;
338+ }
339+ if let Some ( item ) = self . syscall_suspend . pop ( ) {
340+ if let Some ( ( _ , co ) ) = self . syscall . remove ( item . co_name ) {
341+ match co. state ( ) {
342+ CoroutineState :: SystemCall ( val , syscall , SyscallState :: Suspend ( _ ) ) => {
343+ co . syscall ( val , syscall , SyscallState :: Timeout ) ? ;
344+ self . ready . push ( co ) ;
344345 }
346+ _ => unreachable ! ( "check_ready should never execute to here" ) ,
345347 }
346348 }
347349 }
0 commit comments