File tree Expand file tree Collapse file tree 1 file changed +10
-22
lines changed Expand file tree Collapse file tree 1 file changed +10
-22
lines changed Original file line number Diff line number Diff line change @@ -494,28 +494,16 @@ impl BlockedTaskQueue {
494
494
pub fn add_network_timer ( & mut self , wakeup_time : Option < u64 > ) {
495
495
self . network_wakeup_time = wakeup_time;
496
496
497
- match wakeup_time {
498
- Some ( wt) => {
499
- let mut cursor = self . list . cursor_front_mut ( ) ;
500
- if let Some ( node) = cursor. current ( ) {
501
- if node. wakeup_time . is_none ( ) || wt < node. wakeup_time . unwrap ( ) {
502
- arch:: set_oneshot_timer ( wakeup_time) ;
503
- } else {
504
- arch:: set_oneshot_timer ( node. wakeup_time ) ;
505
- }
506
- } else {
507
- arch:: set_oneshot_timer ( wakeup_time) ;
508
- }
509
- }
510
- None => {
511
- let mut cursor = self . list . cursor_front_mut ( ) ;
512
- if let Some ( node) = cursor. current ( ) {
513
- arch:: set_oneshot_timer ( node. wakeup_time ) ;
514
- } else {
515
- arch:: set_oneshot_timer ( None ) ;
516
- }
517
- }
518
- }
497
+ let next = self . list . front ( ) . and_then ( |t| t. wakeup_time ) ;
498
+
499
+ let time = match ( wakeup_time, next) {
500
+ ( Some ( a) , Some ( b) ) => Some ( a. min ( b) ) ,
501
+ ( Some ( a) , None ) => Some ( a) ,
502
+ ( None , Some ( b) ) => Some ( b) ,
503
+ ( None , None ) => None ,
504
+ } ;
505
+
506
+ arch:: set_oneshot_timer ( time) ;
519
507
}
520
508
521
509
/// Blocks the given task for `wakeup_time` ticks, or indefinitely if None is given.
You can’t perform that action at this time.
0 commit comments