Skip to content

Commit

Permalink
use for loop with rev iterator in wake_all
Browse files Browse the repository at this point in the history
  • Loading branch information
Gleb Pomykalov committed Aug 23, 2021
1 parent 7a55899 commit 905dc93
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tokio/src/util/wake_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ impl WakeList {
}

pub(crate) fn wake_all(&mut self) {
assert!(self.curr <= NUM_WAKERS);
while self.curr > 0 {
self.curr -= 1;
let waker = unsafe { ptr::read(self.inner[self.curr].as_mut_ptr()) };
debug_assert!(self.curr <= NUM_WAKERS);

for waker in self.inner[..self.curr].iter_mut().rev() {
let waker = unsafe { std::ptr::read(waker.as_mut_ptr()) };
waker.wake();
}
self.curr = 0;
}
}

Expand Down

0 comments on commit 905dc93

Please sign in to comment.