diff --git a/tokio-timer/src/timeout.rs b/tokio-timer/src/timeout.rs index 8ed1b528b..1c02a6867 100644 --- a/tokio-timer/src/timeout.rs +++ b/tokio-timer/src/timeout.rs @@ -126,7 +126,10 @@ impl Timeout { /// ``` pub fn new(value: T, timeout: Duration) -> Timeout { let delay = Delay::new_timeout(now() + timeout, timeout); + Timeout::new_with_delay(value, delay) + } + pub(crate) fn new_with_delay(value: T, delay: Delay) -> Timeout { Timeout { value, delay } } diff --git a/tokio-timer/src/timer/handle.rs b/tokio-timer/src/timer/handle.rs index ed8f05fd5..c9598b9ae 100644 --- a/tokio-timer/src/timer/handle.rs +++ b/tokio-timer/src/timer/handle.rs @@ -1,5 +1,5 @@ use timer::Inner; -use {Deadline, Delay, Error, Interval}; +use {Deadline, Delay, Error, Interval, Timeout}; use tokio_executor::Enter; @@ -139,11 +139,17 @@ impl Handle { } } - /// Create a `Deadline` driven by this handle's associated `Timer`. + #[doc(hidden)] + #[deprecated(since = "0.2.11", note = "use timeout instead")] pub fn deadline(&self, future: T, deadline: Instant) -> Deadline { Deadline::new_with_delay(future, self.delay(deadline)) } + /// Create a `Timeout` driven by this handle's associated `Timer`. + pub fn timeout(&self, value: T, deadline: Instant) -> Timeout { + Timeout::new_with_delay(value, self.delay(deadline)) + } + /// Create a new `Interval` that starts at `at` and yields every `duration` /// interval after that. pub fn interval(&self, at: Instant, duration: Duration) -> Interval { diff --git a/tokio-timer/tests/hammer.rs b/tokio-timer/tests/hammer.rs index 754cac4d1..9986a9e65 100644 --- a/tokio-timer/tests/hammer.rs +++ b/tokio-timer/tests/hammer.rs @@ -118,7 +118,7 @@ fn hammer_cancel() { let deadline = cmp::min(deadline1, deadline2); let delay = handle.delay(deadline1); - let join = handle.deadline(delay, deadline2); + let join = handle.timeout(delay, deadline2); exec.push({ join.and_then(move |_| {