mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-19 00:00:09 +02:00
timer: Replace Handle::deadline with Handle::timeout (#1074)
Deadline was deprecated a while ago and replaced with Timeout, but the methods on Handle got missed. Fixes #1071
This commit is contained in:
committed by
Carl Lerche
parent
ea282efb2e
commit
219f24cbf1
@@ -126,7 +126,10 @@ impl<T> Timeout<T> {
|
||||
/// ```
|
||||
pub fn new(value: T, timeout: Duration) -> Timeout<T> {
|
||||
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<T> {
|
||||
Timeout { value, delay }
|
||||
}
|
||||
|
||||
|
||||
@@ -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<T>(&self, future: T, deadline: Instant) -> Deadline<T> {
|
||||
Deadline::new_with_delay(future, self.delay(deadline))
|
||||
}
|
||||
|
||||
/// Create a `Timeout` driven by this handle's associated `Timer`.
|
||||
pub fn timeout<T>(&self, value: T, deadline: Instant) -> Timeout<T> {
|
||||
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 {
|
||||
|
||||
@@ -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 |_| {
|
||||
|
||||
Reference in New Issue
Block a user