summaryrefslogtreecommitdiffstats
path: root/tokio/src/time/driver
diff options
context:
space:
mode:
authorTudor Sidea <tudor.sidea@gmail.com>2020-03-24 07:20:07 +0200
committerGitHub <noreply@github.com>2020-03-23 22:20:07 -0700
commit57ba37c97854d32e691ea68006c8d69d58c79b23 (patch)
tree4aa882464266a2f763f7401407b12d4bf6613283 /tokio/src/time/driver
parentacf8a7da7a64bf08d578db9a9836a8e061765314 (diff)
time: fix repeated pause/resume of time (#2253)
The resume function was breaking the guarantee that Instants should never be less than any previously measured Instants when created. Altered the pause and resume function such that they will not break this guarantee. After resume, the time should continue from where it left off. Created test to prove that the advanced function still works as expected. Added additional tests for the pause/advance/resume functions.
Diffstat (limited to 'tokio/src/time/driver')
-rw-r--r--tokio/src/time/driver/mod.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/tokio/src/time/driver/mod.rs b/tokio/src/time/driver/mod.rs
index 91444341..bb45cb7e 100644
--- a/tokio/src/time/driver/mod.rs
+++ b/tokio/src/time/driver/mod.rs
@@ -247,7 +247,7 @@ where
if deadline > now {
let dur = deadline - now;
- if self.clock.is_frozen() {
+ if self.clock.is_paused() {
self.park.park_timeout(Duration::from_secs(0))?;
self.clock.advance(dur);
} else {
@@ -278,7 +278,7 @@ where
if deadline > now {
let duration = cmp::min(deadline - now, duration);
- if self.clock.is_frozen() {
+ if self.clock.is_paused() {
self.park.park_timeout(Duration::from_secs(0))?;
self.clock.advance(duration);
} else {