diff --git a/tokio/src/util/wake_list.rs b/tokio/src/util/wake_list.rs index bd3899563b6..f72850b6f78 100644 --- a/tokio/src/util/wake_list.rs +++ b/tokio/src/util/wake_list.rs @@ -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; } }