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

@@ -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,
}
}
}