mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-09 00:00:08 +02:00
time: wake DelayQueue when removing last item (#6752)
This commit is contained in:
@@ -766,6 +766,12 @@ impl<T> DelayQueue<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if self.slab.is_empty() {
|
||||||
|
if let Some(waker) = self.waker.take() {
|
||||||
|
waker.wake();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Expired {
|
Expired {
|
||||||
key: Key::new(key.index),
|
key: Key::new(key.index),
|
||||||
data: data.inner,
|
data: data.inner,
|
||||||
|
|||||||
@@ -880,6 +880,19 @@ async fn peek() {
|
|||||||
assert!(queue.peek().is_none());
|
assert!(queue.peek().is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test(start_paused = true)]
|
||||||
|
async fn wake_after_remove_last() {
|
||||||
|
let mut queue = task::spawn(DelayQueue::new());
|
||||||
|
let key = queue.insert("foo", ms(1000));
|
||||||
|
|
||||||
|
assert_pending!(poll!(queue));
|
||||||
|
|
||||||
|
queue.remove(&key);
|
||||||
|
|
||||||
|
assert!(queue.is_woken());
|
||||||
|
assert!(assert_ready!(poll!(queue)).is_none());
|
||||||
|
}
|
||||||
|
|
||||||
fn ms(n: u64) -> Duration {
|
fn ms(n: u64) -> Duration {
|
||||||
Duration::from_millis(n)
|
Duration::from_millis(n)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user