Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

time: avoid traversing entries in the time wheel twice #6718

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
rm model in the reset_timer_and_drop test
wathenjiang committed Jul 24, 2024
commit 71f60d516ad154a3e6de99a05295f74c045177dc
24 changes: 11 additions & 13 deletions tokio/src/runtime/time/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -205,23 +205,21 @@ fn reset_future() {
#[test]
#[cfg(not(loom))]
fn reset_timer_and_drop() {
model(|| {
let rt = rt(false);
let handle = rt.handle();
let rt = rt(false);
let handle = rt.handle();

let start = handle.inner.driver().clock().now();
let start = handle.inner.driver().clock().now();

for _ in 0..2 {
let entry = TimerEntry::new(handle.inner.clone(), start + Duration::from_millis(10));
pin!(entry);
for _ in 0..2 {
let entry = TimerEntry::new(handle.inner.clone(), start + Duration::from_millis(10));
pin!(entry);

let _ = entry
.as_mut()
.poll_elapsed(&mut Context::from_waker(futures::task::noop_waker_ref()));
let _ = entry
.as_mut()
.poll_elapsed(&mut Context::from_waker(futures::task::noop_waker_ref()));

entry.as_mut().reset(start + Duration::from_secs(1), true);
}
});
entry.as_mut().reset(start + Duration::from_secs(1), true);
}
}

#[cfg(not(loom))]