mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-25 00:00:18 +02:00
time: clean time driver (#2905)
* remove unnecessary wheel::Poll the timer wheel uses the `wheel::Poll` struct as input when advancing the timer to the next time step. the `Poll` struct contains an instant representing the time step to advance to and also contains an optional and mutable reference to an `Expiration` struct. from what I can tell, the latter field is only used in the context of polling the wheel and does not need to be exposed outside of that method. without the expiration field the `Poll` struct is nothing more than a wrapper around the instant being polled. this change removes the `Poll` struct and updates integration points accordingly. * remove Stack trait in favor of concrete Stack implementation * remove timer Registration struct
This commit is contained in:
@@ -141,7 +141,7 @@ pub struct DelayQueue<T> {
|
||||
delay: Option<Delay>,
|
||||
|
||||
/// Wheel polling state
|
||||
poll: wheel::Poll,
|
||||
wheel_now: u64,
|
||||
|
||||
/// Instant at which the timer starts
|
||||
start: Instant,
|
||||
@@ -251,7 +251,7 @@ impl<T> DelayQueue<T> {
|
||||
slab: Slab::with_capacity(capacity),
|
||||
expired: Stack::default(),
|
||||
delay: None,
|
||||
poll: wheel::Poll::new(0),
|
||||
wheel_now: 0,
|
||||
start: Instant::now(),
|
||||
}
|
||||
}
|
||||
@@ -733,11 +733,11 @@ impl<T> DelayQueue<T> {
|
||||
|
||||
let now = crate::time::ms(delay.deadline() - self.start, crate::time::Round::Down);
|
||||
|
||||
self.poll = wheel::Poll::new(now);
|
||||
self.wheel_now = now;
|
||||
}
|
||||
|
||||
// We poll the wheel to get the next value out before finding the next deadline.
|
||||
let wheel_idx = self.wheel.poll(&mut self.poll, &mut self.slab);
|
||||
let wheel_idx = self.wheel.poll(self.wheel_now, &mut self.slab);
|
||||
|
||||
self.delay = self.next_deadline().map(sleep_until);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user