From 34a9dc2d764a5f413d365ed4af94f6af4c42a14a Mon Sep 17 00:00:00 2001 From: John-John Tedro Date: Mon, 19 Aug 2019 16:21:34 +0200 Subject: [PATCH] Implement FusedStream and FusedFuture for Interval and Delay (#1476) --- tokio-timer/src/delay.rs | 7 +++++++ tokio-timer/src/interval.rs | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/tokio-timer/src/delay.rs b/tokio-timer/src/delay.rs index 41210690e..7ba8be758 100644 --- a/tokio-timer/src/delay.rs +++ b/tokio-timer/src/delay.rs @@ -91,6 +91,13 @@ impl Delay { } } +#[cfg(feature = "async-traits")] +impl futures_core::FusedFuture for Delay { + fn is_terminated(&self) -> bool { + self.is_elapsed() + } +} + impl Future for Delay { type Output = (); diff --git a/tokio-timer/src/interval.rs b/tokio-timer/src/interval.rs index 31e003f21..ea5ca7d4a 100644 --- a/tokio-timer/src/interval.rs +++ b/tokio-timer/src/interval.rs @@ -100,6 +100,13 @@ impl Interval { } } +#[cfg(feature = "async-traits")] +impl futures_core::FusedStream for Interval { + fn is_terminated(&self) -> bool { + false + } +} + #[cfg(feature = "async-traits")] impl futures_core::Stream for Interval { type Item = Instant;