feat(lib): Upgrade to Tokio 1.0 (#2369)

Closes #2370
This commit is contained in:
Sean McArthur
2020-12-23 10:36:12 -08:00
committed by GitHub
parent dad5c8792f
commit fad42acc79
14 changed files with 71 additions and 146 deletions

View File

@@ -667,8 +667,11 @@ impl ConnectingTcp<'_> {
let fallback_fut = fallback.remote.connect(self.config);
futures_util::pin_mut!(fallback_fut);
let fallback_delay = fallback.delay;
futures_util::pin_mut!(fallback_delay);
let (result, future) =
match futures_util::future::select(preferred_fut, fallback.delay).await {
match futures_util::future::select(preferred_fut, fallback_delay).await {
Either::Left((result, _fallback_delay)) => {
(result, Either::Right(fallback_fut))
}

View File

@@ -1,7 +1,7 @@
#[cfg(feature = "http2")]
use std::future::Future;
use tokio::stream::Stream;
use futures_util::FutureExt;
use tokio::sync::{mpsc, oneshot};
use crate::common::{task, Pin, Poll};
@@ -150,8 +150,8 @@ impl<T, U> Receiver<T, U> {
self: Pin<&mut Self>,
cx: &mut task::Context<'_>,
) -> Poll<Option<(T, Callback<T, U>)>> {
let this = self.project();
match this.inner.poll_next(cx) {
let mut this = self.project();
match this.inner.poll_recv(cx) {
Poll::Ready(item) => {
Poll::Ready(item.map(|mut env| env.0.take().expect("envelope not dropped")))
}
@@ -170,9 +170,9 @@ impl<T, U> Receiver<T, U> {
#[cfg(feature = "http1")]
pub(crate) fn try_recv(&mut self) -> Option<(T, Callback<T, U>)> {
match self.inner.try_recv() {
Ok(mut env) => env.0.take(),
Err(_) => None,
match self.inner.recv().now_or_never() {
Some(Some(mut env)) => env.0.take(),
_ => None,
}
}
}

View File

@@ -731,7 +731,6 @@ impl<T: Poolable + 'static> Future for IdleTask<T> {
type Output = ();
fn poll(self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> {
use tokio::stream::Stream;
let mut this = self.project();
loop {
match this.pool_drop_notifier.as_mut().poll(cx) {
@@ -743,7 +742,7 @@ impl<T: Poolable + 'static> Future for IdleTask<T> {
}
}
ready!(this.interval.as_mut().poll_next(cx));
ready!(this.interval.as_mut().poll_tick(cx));
if let Some(inner) = this.pool.upgrade() {
if let Ok(mut inner) = inner.lock() {