Prune the futures dependencies

This commit is contained in:
Constantin Nickel
2019-09-12 14:45:37 +02:00
committed by Sean McArthur
parent 5a337ba739
commit b1a90eb402
12 changed files with 54 additions and 45 deletions

View File

@@ -5,8 +5,8 @@ use std::sync::Arc;
use std::thread;
use std::time::Duration;
use futures::channel::{mpsc, oneshot};
use futures::{StreamExt, TryFutureExt};
use futures_channel::{mpsc, oneshot};
use futures_util::{StreamExt, TryFutureExt};
use log::{error, trace};
@@ -652,15 +652,15 @@ where
{
use std::task::Poll;
futures::pin_mut!(fut);
futures_util::pin_mut!(fut);
// "select" on the sender being canceled, and the future completing
let res = futures::future::poll_fn(|cx| {
let res = futures_util::future::poll_fn(|cx| {
match fut.as_mut().poll(cx) {
Poll::Ready(val) => Poll::Ready(Some(val)),
Poll::Pending => {
// check if the callback is canceled
futures::ready!(tx.poll_cancel(cx));
futures_core::ready!(tx.poll_cancel(cx));
Poll::Ready(None)
}
}

View File

@@ -17,7 +17,7 @@ use crate::{async_impl, StatusCode, Url, Version};
/// A Response to a submitted `Request`.
pub struct Response {
inner: async_impl::Response,
body: Option<Pin<Box<dyn futures::io::AsyncRead + Send + Sync>>>,
body: Option<Pin<Box<dyn futures_util::io::AsyncRead + Send + Sync>>>,
timeout: Option<Duration>,
_thread_handle: KeepCoreThreadAlive,
}
@@ -340,8 +340,8 @@ impl Response {
// private
fn body_mut(&mut self) -> Pin<&mut dyn futures::io::AsyncRead> {
use futures::stream::TryStreamExt;
fn body_mut(&mut self) -> Pin<&mut dyn futures_util::io::AsyncRead> {
use futures_util::TryStreamExt;
if self.body.is_none() {
let body = mem::replace(self.inner.body_mut(), async_impl::Decoder::empty());
@@ -355,7 +355,7 @@ impl Response {
impl Read for Response {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
use futures::io::AsyncReadExt;
use futures_util::io::AsyncReadExt;
let timeout = self.timeout;
wait::timeout(self.body_mut().read(buf), timeout).map_err(|e| match e {

View File

@@ -23,10 +23,10 @@ where
let mut park = ParkThread::new();
// Arc shouldn't be necessary, since UnparkThread is reference counted internally,
// but let's just stay safe for now.
let waker = futures::task::waker(Arc::new(UnparkWaker(park.unpark())));
let waker = futures_util::task::waker(Arc::new(UnparkWaker(park.unpark())));
let mut cx = Context::from_waker(&waker);
futures::pin_mut!(fut);
futures_util::pin_mut!(fut);
loop {
match fut.as_mut().poll(&mut cx) {
@@ -60,7 +60,7 @@ pub(crate) enum Waited<E> {
struct UnparkWaker(UnparkThread);
impl futures::task::ArcWake for UnparkWaker {
impl futures_util::task::ArcWake for UnparkWaker {
fn wake_by_ref(arc_self: &Arc<Self>) {
arc_self.0.unpark();
}