From 6fb62d32322a5d09a003757d4223597e0cc34534 Mon Sep 17 00:00:00 2001 From: Yuanchao Sun Date: Tue, 27 Jun 2017 11:34:56 +0800 Subject: [PATCH] Add a method to reset Timeout. --- src/reactor/timeout.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/reactor/timeout.rs b/src/reactor/timeout.rs index 76fba9fd4..604dccca0 100644 --- a/src/reactor/timeout.rs +++ b/src/reactor/timeout.rs @@ -46,6 +46,13 @@ impl Timeout { handle: handle.remote().clone(), }) } + + /// Resets this timeout to an new timeout which will fire at the time + /// specified by `at`. + pub fn reset(&mut self, at: Instant) { + self.when = at; + self.token.reset_timeout(self.when, &self.handle); + } } impl Future for Timeout {