diff --git a/src/sources/timer.rs b/src/sources/timer.rs index 7a4cba85..2b164dc3 100644 --- a/src/sources/timer.rs +++ b/src/sources/timer.rs @@ -229,6 +229,16 @@ impl TimerWheel { } pub(crate) fn cancel(&mut self, counter: u32) { + if self + .heap + .peek() + .map(|data| data.counter == counter) + .unwrap_or(false) + { + self.heap.pop(); + return; + }; + self.heap .iter() .find(|data| data.counter == counter)