Update futures and tokio alphas

This commit is contained in:
Sean McArthur
2019-08-29 14:25:17 -07:00
parent f4378bae58
commit 678c90eb0a
12 changed files with 32 additions and 27 deletions

View File

@@ -44,9 +44,9 @@ members = [
]
[dependencies]
futures-preview = "0.3.0-alpha.18"
tokio-io = { version = "0.2.0-alpha.2", features = ["util"] }
tokio-codec = "0.2.0-alpha.2"
futures-preview = "=0.3.0-alpha.18"
tokio-io = { version = "=0.2.0-alpha.4", features = ["util"] }
tokio-codec = "=0.2.0-alpha.4"
bytes = "0.4.7"
http = "0.1.8"
log = "0.4.1"
@@ -68,7 +68,7 @@ serde = "1.0.0"
serde_json = "1.0.0"
# Akamai example
tokio = "0.2.0-alpha.2"
tokio = "=0.2.0-alpha.4"
env_logger = { version = "0.5.3", default-features = false }
rustls = "0.12"
tokio-rustls = "0.5.0"

View File

@@ -9,7 +9,7 @@ use tokio::net::TcpStream;
pub async fn main() -> Result<(), Box<dyn Error>> {
let _ = env_logger::try_init();
let tcp = TcpStream::connect(&"127.0.0.1:5928".parse().unwrap()).await?;
let tcp = TcpStream::connect("127.0.0.1:5928").await?;
let (mut client, h2) = client::handshake(tcp).await?;
println!("sending request");

View File

@@ -10,7 +10,7 @@ use tokio::net::{TcpListener, TcpStream};
pub async fn main() -> Result<(), Box<dyn Error>> {
let _ = env_logger::try_init();
let mut listener = TcpListener::bind(&"127.0.0.1:5928".parse()?)?;
let mut listener = TcpListener::bind("127.0.0.1:5928").await?;
println!("listening on {:?}", listener.local_addr());

View File

@@ -74,10 +74,8 @@
//!
//! #[tokio::main]
//! pub async fn main() -> Result<(), Box<dyn Error>> {
//! let addr = "127.0.0.1:5928".parse().unwrap();
//!
//! // Establish TCP connection to the server.
//! let tcp = TcpStream::connect(&addr).await?;
//! let tcp = TcpStream::connect("127.0.0.1:5928").await?;
//! let (h2, connection) = client::handshake(tcp).await?;
//! tokio::spawn(async move {
//! connection.await.unwrap();

View File

@@ -70,8 +70,7 @@
//!
//! #[tokio::main]
//! pub async fn main() {
//! let addr = "127.0.0.1:5928".parse().unwrap();
//! let mut listener = TcpListener::bind(&addr).unwrap();
//! let mut listener = TcpListener::bind("127.0.0.1:5928").await.unwrap();
//!
//! // Accept all incoming TCP connections.
//! loop {

View File

@@ -9,7 +9,7 @@ edition = "2018"
h2 = { path = "../.." }
env_logger = { version = "0.5.3", default-features = false }
futures-preview = "0.3.0-alpha.17"
futures-preview = "=0.3.0-alpha.18"
honggfuzz = "0.5"
http = "0.1.3"
tokio = "0.2.0-alpha.1"
tokio = "=0.2.0-alpha.4"

View File

@@ -9,7 +9,7 @@ h2 = { path = "../..", features = ["stream", "unstable"] }
bytes = "0.4.7"
env_logger = "0.5.9"
futures-preview = "0.3.0-alpha.17"
futures-preview = "=0.3.0-alpha.18"
http = "0.1.5"
string = "0.2"
tokio = "0.2.0-alpha.1"
tokio = "=0.2.0-alpha.4"

View File

@@ -7,14 +7,13 @@ use futures::future::poll_fn;
use futures::{ready, Stream, StreamExt};
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt};
use tokio::timer::Delay;
use super::assert::assert_frame_eq;
use futures::executor::block_on;
use std::pin::Pin;
use std::sync::{Arc, Mutex};
use std::task::{Context, Poll, Waker};
use std::time::{Duration, Instant};
use std::time::Duration;
use std::{cmp, io, usize};
/// A mock I/O
@@ -483,5 +482,5 @@ impl AsyncWrite for Pipe {
}
pub async fn idle_ms(ms: u64) {
Delay::new(Instant::now() + Duration::from_millis(ms)).await
tokio::timer::delay(tokio::clock::now() + Duration::from_millis(ms)).await
}

View File

@@ -396,7 +396,7 @@ mod tokio_ {
match self.inner.read(buf) {
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {
if let Some(rem) = self.inner.remaining_wait() {
self.tokio.sleep = Some(Delay::new(Instant::now() + rem));
self.tokio.sleep = Some(tokio::timer::delay(Instant::now() + rem));
} else {
self.tokio.read_wait = Some(cx.waker().clone());
return Poll::Pending;
@@ -440,7 +440,7 @@ mod tokio_ {
match self.inner.write(buf) {
Err(ref e) if e.kind() == io::ErrorKind::WouldBlock => {
if let Some(rem) = self.inner.remaining_wait() {
self.tokio.sleep = Some(Delay::new(Instant::now() + rem));
self.tokio.sleep = Some(tokio::timer::delay(Instant::now() + rem));
} else {
panic!("unexpected WouldBlock");
}

View File

@@ -10,5 +10,5 @@ edition = "2018"
[dev-dependencies]
h2-support = { path = "../h2-support" }
log = "0.4.1"
futures-preview = "0.3.0-alpha.17"
tokio = "0.2.0-alpha.1"
futures-preview = "=0.3.0-alpha.18"
tokio = "=0.2.0-alpha.4"

View File

@@ -947,7 +947,6 @@ async fn settings_lowered_capacity_returns_capacity_to_connection() {
use futures::channel::oneshot;
use futures::future::{select, Either};
use std::time::Instant;
use tokio::timer::Delay;
let _ = env_logger::try_init();
let (io, mut srv) = mock::new();
@@ -979,7 +978,11 @@ async fn settings_lowered_capacity_returns_capacity_to_connection() {
//
// A timeout is used here to avoid blocking forever if there is a
// failure
let result = select(rx2, Delay::new(Instant::now() + Duration::from_secs(5))).await;
let result = select(
rx2,
tokio::timer::delay(Instant::now() + Duration::from_secs(5)),
)
.await;
if let Either::Right((_, _)) = result {
panic!("Timed out");
}
@@ -1011,7 +1014,11 @@ async fn settings_lowered_capacity_returns_capacity_to_connection() {
});
// Wait for server handshake to complete.
let result = select(rx1, Delay::new(Instant::now() + Duration::from_secs(5))).await;
let result = select(
rx1,
tokio::timer::delay(Instant::now() + Duration::from_secs(5)),
)
.await;
if let Either::Right((_, _)) = result {
panic!("Timed out");
}

View File

@@ -26,7 +26,10 @@ impl Server {
{
let mk_data = Arc::new(mk_data);
let listener = TcpListener::bind(&SocketAddr::from(([127, 0, 0, 1], 0))).unwrap();
let rt = tokio::runtime::Runtime::new().unwrap();
let listener = rt
.block_on(TcpListener::bind(SocketAddr::from(([127, 0, 0, 1], 0))))
.unwrap();
let addr = listener.local_addr().unwrap();
let reqs = Arc::new(AtomicUsize::new(0));
let reqs2 = reqs.clone();
@@ -44,7 +47,6 @@ impl Server {
}
};
let rt = tokio::runtime::Runtime::new().unwrap();
rt.block_on(server);
});