Update to Tokio 0.2 (#428)
This commit is contained in:
@@ -5,18 +5,18 @@ use crate::{client, frame, proto, server};
|
||||
use crate::frame::DEFAULT_INITIAL_WINDOW_SIZE;
|
||||
use crate::proto::*;
|
||||
|
||||
use bytes::{Bytes, IntoBuf};
|
||||
use bytes::{Buf, Bytes};
|
||||
use futures_core::Stream;
|
||||
use std::io;
|
||||
use std::marker::PhantomData;
|
||||
use std::pin::Pin;
|
||||
use std::task::{Context, Poll};
|
||||
use std::time::Duration;
|
||||
use tokio_io::{AsyncRead, AsyncWrite};
|
||||
use tokio::io::{AsyncRead, AsyncWrite};
|
||||
|
||||
/// An H2 connection
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct Connection<T, P, B: IntoBuf = Bytes>
|
||||
pub(crate) struct Connection<T, P, B: Buf = Bytes>
|
||||
where
|
||||
P: Peer,
|
||||
{
|
||||
@@ -30,7 +30,7 @@ where
|
||||
error: Option<Reason>,
|
||||
|
||||
/// Read / write frame values
|
||||
codec: Codec<T, Prioritized<B::Buf>>,
|
||||
codec: Codec<T, Prioritized<B>>,
|
||||
|
||||
/// Pending GOAWAY frames to write.
|
||||
go_away: GoAway,
|
||||
@@ -42,7 +42,7 @@ where
|
||||
settings: Settings,
|
||||
|
||||
/// Stream state handler
|
||||
streams: Streams<B::Buf, P>,
|
||||
streams: Streams<B, P>,
|
||||
|
||||
/// Client or server
|
||||
_phantom: PhantomData<P>,
|
||||
@@ -73,10 +73,9 @@ impl<T, P, B> Connection<T, P, B>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite + Unpin,
|
||||
P: Peer,
|
||||
B: IntoBuf + Unpin,
|
||||
B::Buf: Unpin,
|
||||
B: Buf + Unpin,
|
||||
{
|
||||
pub fn new(codec: Codec<T, Prioritized<B::Buf>>, config: Config) -> Connection<T, P, B> {
|
||||
pub fn new(codec: Codec<T, Prioritized<B>>, config: Config) -> Connection<T, P, B> {
|
||||
let streams = Streams::new(streams::Config {
|
||||
local_init_window_sz: config
|
||||
.settings
|
||||
@@ -385,9 +384,9 @@ where
|
||||
impl<T, B> Connection<T, client::Peer, B>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite,
|
||||
B: IntoBuf,
|
||||
B: Buf,
|
||||
{
|
||||
pub(crate) fn streams(&self) -> &Streams<B::Buf, client::Peer> {
|
||||
pub(crate) fn streams(&self) -> &Streams<B, client::Peer> {
|
||||
&self.streams
|
||||
}
|
||||
}
|
||||
@@ -395,10 +394,9 @@ where
|
||||
impl<T, B> Connection<T, server::Peer, B>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite + Unpin,
|
||||
B: IntoBuf + Unpin,
|
||||
B::Buf: Unpin,
|
||||
B: Buf + Unpin,
|
||||
{
|
||||
pub fn next_incoming(&mut self) -> Option<StreamRef<B::Buf>> {
|
||||
pub fn next_incoming(&mut self) -> Option<StreamRef<B>> {
|
||||
self.streams.next_incoming()
|
||||
}
|
||||
|
||||
@@ -431,7 +429,7 @@ where
|
||||
impl<T, P, B> Drop for Connection<T, P, B>
|
||||
where
|
||||
P: Peer,
|
||||
B: IntoBuf,
|
||||
B: Buf,
|
||||
{
|
||||
fn drop(&mut self) {
|
||||
// Ignore errors as this indicates that the mutex is poisoned.
|
||||
|
||||
@@ -4,7 +4,7 @@ use crate::frame::{self, Reason, StreamId};
|
||||
use bytes::Buf;
|
||||
use std::io;
|
||||
use std::task::{Context, Poll};
|
||||
use tokio_io::AsyncWrite;
|
||||
use tokio::io::AsyncWrite;
|
||||
|
||||
/// Manages our sending of GOAWAY frames.
|
||||
#[derive(Debug)]
|
||||
|
||||
@@ -23,7 +23,7 @@ use crate::frame::{self, Frame};
|
||||
|
||||
use bytes::Buf;
|
||||
|
||||
use tokio_io::AsyncWrite;
|
||||
use tokio::io::AsyncWrite;
|
||||
|
||||
pub type PingPayload = [u8; 8];
|
||||
|
||||
|
||||
@@ -3,12 +3,12 @@ use crate::frame::Ping;
|
||||
use crate::proto::{self, PingPayload};
|
||||
|
||||
use bytes::Buf;
|
||||
use futures_util::task::AtomicWaker;
|
||||
use std::io;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
use std::sync::Arc;
|
||||
use std::task::{Context, Poll};
|
||||
use tokio_io::AsyncWrite;
|
||||
use tokio_sync::AtomicWaker;
|
||||
use tokio::io::AsyncWrite;
|
||||
|
||||
/// Acknowledges ping requests from the remote.
|
||||
#[derive(Debug)]
|
||||
@@ -190,7 +190,7 @@ impl PingPong {
|
||||
.state
|
||||
.store(USER_STATE_PENDING_PONG, Ordering::Release);
|
||||
} else {
|
||||
users.0.ping_task.register_by_ref(cx.waker());
|
||||
users.0.ping_task.register(cx.waker());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,7 +233,7 @@ impl UserPings {
|
||||
pub(crate) fn poll_pong(&self, cx: &mut Context) -> Poll<Result<(), proto::Error>> {
|
||||
// Must register before checking state, in case state were to change
|
||||
// before we could register, and then the ping would just be lost.
|
||||
self.0.pong_task.register_by_ref(cx.waker());
|
||||
self.0.pong_task.register(cx.waker());
|
||||
let prev = self.0.state.compare_and_swap(
|
||||
USER_STATE_RECEIVED_PONG, // current
|
||||
USER_STATE_EMPTY, // new
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::frame::{Reason, StreamId};
|
||||
use crate::codec::UserError;
|
||||
use crate::codec::UserError::*;
|
||||
|
||||
use bytes::buf::Take;
|
||||
use bytes::buf::ext::{BufExt, Take};
|
||||
use std::io;
|
||||
use std::task::{Context, Poll, Waker};
|
||||
use std::{cmp, fmt, mem};
|
||||
|
||||
@@ -8,7 +8,7 @@ use crate::frame::{self, Reason};
|
||||
use bytes::Buf;
|
||||
use http;
|
||||
use std::task::{Context, Poll, Waker};
|
||||
use tokio_io::AsyncWrite;
|
||||
use tokio::io::AsyncWrite;
|
||||
|
||||
use std::io;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ use crate::{client, proto, server};
|
||||
use bytes::{Buf, Bytes};
|
||||
use http::{HeaderMap, Request, Response};
|
||||
use std::task::{Context, Poll, Waker};
|
||||
use tokio_io::AsyncWrite;
|
||||
use tokio::io::AsyncWrite;
|
||||
|
||||
use crate::PollExt;
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
Reference in New Issue
Block a user