Update Tokio to use std::future. (#1120)

A first pass at updating Tokio to use `std::future`.

Implementations of `Future` from the futures crate are updated to implement
`Future` from std. Implementations of `Stream` are moved to a feature flag.

This commits disables a number of crates that have not yet been updated.
This commit is contained in:
Carl Lerche
2019-06-24 12:34:30 -07:00
committed by GitHub
parent aa99950b9c
commit 06c473e628
150 changed files with 2694 additions and 9825 deletions
+9 -6
View File
@@ -1,6 +1,9 @@
use crate::clock;
use crate::Delay;
use futures::{try_ready, Future, Poll, Stream};
use futures_core::Stream;
use std::future::Future;
use std::pin::Pin;
use std::task::{self, Poll};
use std::time::{Duration, Instant};
/// A stream representing notifications at fixed interval
@@ -53,20 +56,20 @@ impl Interval {
impl Stream for Interval {
type Item = Instant;
type Error = crate::Error;
fn poll(&mut self) -> Poll<Option<Self::Item>, Self::Error> {
fn poll_next(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Option<Self::Item>> {
// Wait for the delay to be done
let _ = try_ready!(self.delay.poll());
ready!(Pin::new(&mut self.delay).poll(cx));
// Get the `now` by looking at the `delay` deadline
let now = self.delay.deadline();
// The next interval value is `duration` after the one that just
// yielded.
self.delay.reset(now + self.duration);
let next = now + self.duration;
self.delay.reset(next);
// Return the current instant
Ok(Some(now).into())
Poll::Ready(Some(now))
}
}