fix time calc after time driver stop

This commit is contained in:
Nikolay Kim 2021-10-29 22:03:44 +06:00
parent c3016a1ae9
commit 862530b1a0

View file

@ -566,8 +566,10 @@ impl Future for TimerDriver {
if inner.flags.contains(Flags::DRIVER_RECALC) { if inner.flags.contains(Flags::DRIVER_RECALC) {
inner.flags.remove(Flags::DRIVER_RECALC); inner.flags.remove(Flags::DRIVER_RECALC);
let deadline = let now = Instant::now();
Instant::now() + Duration::from_millis(inner.next_expiry_ms()); let deadline = now
+ Duration::from_millis(inner.next_expiry_ms())
.saturating_sub(now - inner.elapsed_time());
Pin::as_mut(&mut inner.driver_sleep).reset(deadline); Pin::as_mut(&mut inner.driver_sleep).reset(deadline);
} }