Skip to content

feat: update to Tokio 0.3 #2317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
9e52e64
Bump tokio (and related dependencies)
Urhengulas Oct 24, 2020
9c75fc7
WIP: update h2 (git dependency)
Urhengulas Oct 24, 2020
842ad6e
Sleep changes
Urhengulas Oct 24, 2020
538f70f
Adapt AsyncRead, AsynWrite
Urhengulas Oct 24, 2020
8b0a321
TcpStream::connect_std -> from_std
Urhengulas Oct 24, 2020
d60d8a3
WIP: adapt tests
Urhengulas Oct 24, 2020
764ae4b
update connect::http
hawkw Oct 28, 2020
126f0bc
start updating client dispatch
hawkw Oct 28, 2020
b1ef66e
whoa, everything important compiles!
hawkw Oct 28, 2020
4d2b45e
put back connect timeout
hawkw Oct 28, 2020
594e1b2
update tests
hawkw Oct 28, 2020
b7d1392
warnings
hawkw Oct 28, 2020
50aaa5a
fix examples
hawkw Oct 28, 2020
b70d46e
update benchmarks
hawkw Oct 28, 2020
f9d466e
fix write bufs not being advanced
hawkw Oct 28, 2020
5573b6c
hmm i've messed something up
hawkw Oct 29, 2020
29d4246
fix read buf always being empty
hawkw Oct 29, 2020
e005e85
cleanup
hawkw Oct 29, 2020
b5febd1
fix fd being closed by dropping socket2 socket
hawkw Oct 29, 2020
041d631
support sockopts on windows in server
hawkw Oct 29, 2020
21d41b1
fix test panicking because i forgot to use try_init
hawkw Oct 29, 2020
16c8130
apparently we have to set O_NONBLOCK ourselves :(
hawkw Oct 29, 2020
5eb4d29
fix AddrIncoming not setting O_NONBLOCK
hawkw Oct 29, 2020
2d08635
put back return removed in 538f70ffe73ffcf129480d4a7425437067df9bc6
hawkw Oct 29, 2020
9939cfc
un-format cargo.toml
hawkw Oct 29, 2020
be1a86c
Merge branch 'master' into eliza/bump-tokio
hawkw Oct 29, 2020
33d0ba4
bump msrv to track Tokio's
hawkw Oct 30, 2020
527c4b5
Merge branch 'eliza/bump-tokio' of github.com:hawkw/hyper into eliza/…
hawkw Oct 30, 2020
8cb89d1
Merge branch 'master' into eliza/bump-tokio
hawkw Nov 2, 2020
3d8c5b8
Merge branch 'master' into eliza/bump-tokio
hawkw Nov 3, 2020
7fd643a
remove dependency on tokio 0.2
hawkw Nov 3, 2020
28e3ecd
rm mut
hawkw Nov 4, 2020
d6599ff
fix drains completing early
hawkw Nov 4, 2020
bddd3c8
update benchmarks
hawkw Nov 4, 2020
4ee2b9f
oh no there were more Secret Hidden Benchmarks ._.
hawkw Nov 4, 2020
994897a
fix IntoRawFd on windows
hawkw Nov 5, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- stable
- beta
- nightly
- 1.39.0
- 1.45.2

os:
- ubuntu-latest
Expand Down
27 changes: 18 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

[package]
name = "hyper"
version = "0.14.0-dev" # don't forget to update html_root_url
Expand Down Expand Up @@ -30,12 +31,12 @@ http = "0.2"
http-body = "0.3.1"
httpdate = "0.3"
httparse = "1.0"
h2 = "0.2.2"
h2 = { git = "https://github.com/hyperium/h2" }
itoa = "0.4.1"
tracing = { version = "0.1", default-features = false, features = ["log", "std"] }
pin-project = "1.0"
tower-service = "0.3"
tokio = { version = "0.2.11", features = ["sync"] }
tokio = { version = "0.3", features = ["sync", "stream"] }
want = "0.3"

# Optional
Expand All @@ -51,9 +52,18 @@ spmc = "0.3"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
tokio = { version = "0.2.2", features = ["fs", "macros", "io-std", "rt-util", "sync", "time", "test-util"] }
tokio-test = "0.2"
tokio-util = { version = "0.3", features = ["codec"] }
tokio = { version = "0.3", features = [
"fs",
"macros",
"io-std",
"rt",
"rt-multi-thread", # so examples can use #[tokio::main]
"sync",
"time",
"test-util",
] }
tokio-test = "0.3"
tokio-util = { version = "0.4", features = ["codec"] }
tower-util = "0.3"
url = "1.0"

Expand All @@ -67,12 +77,12 @@ default = [
]
runtime = [
"tcp",
"tokio/rt-core",
"tokio/rt",
]
tcp = [
"socket2",
"tokio/blocking",
"tokio/tcp",
"tokio/net",
"tokio/rt",
"tokio/time",
]

Expand Down Expand Up @@ -219,4 +229,3 @@ required-features = ["runtime", "stream"]
name = "server"
path = "tests/server.rs"
required-features = ["runtime"]

3 changes: 1 addition & 2 deletions benches/body.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ use hyper::body::Body;

macro_rules! bench_stream {
($bencher:ident, bytes: $bytes:expr, count: $count:expr, $total_ident:ident, $body_pat:pat, $block:expr) => {{
let mut rt = tokio::runtime::Builder::new()
.basic_scheduler()
let rt = tokio::runtime::Builder::new_current_thread()
.build()
.expect("rt build");

Expand Down
5 changes: 2 additions & 3 deletions benches/connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ use tokio::net::TcpListener;
#[bench]
fn http_connector(b: &mut test::Bencher) {
let _ = pretty_env_logger::try_init();
let mut rt = tokio::runtime::Builder::new()
let rt = tokio::runtime::Builder::new_current_thread()
.enable_all()
.basic_scheduler()
.build()
.expect("rt build");
let mut listener = rt
let listener = rt
.block_on(TcpListener::bind(&SocketAddr::from(([127, 0, 0, 1], 0))))
.expect("bind");
let addr = listener.local_addr().expect("local_addr");
Expand Down
18 changes: 10 additions & 8 deletions benches/end_to_end.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,14 +270,16 @@ impl Opts {
}

fn bench(self, b: &mut test::Bencher) {
use std::sync::Arc;
let _ = pretty_env_logger::try_init();
// Create a runtime of current thread.
let mut rt = tokio::runtime::Builder::new()
.enable_all()
.basic_scheduler()
.build()
.expect("rt build");
let exec = rt.handle().clone();
let rt = Arc::new(
tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("rt build"),
);
let exec = rt.clone();

let req_len = self.request_body.map(|b| b.len()).unwrap_or(0) as u64;
let req_len = if self.request_chunks > 0 {
Expand All @@ -288,7 +290,7 @@ impl Opts {
let bytes_per_iter = (req_len + self.response_body.len() as u64) * self.parallel_cnt as u64;
b.bytes = bytes_per_iter;

let addr = spawn_server(&mut rt, &self);
let addr = spawn_server(&rt, &self);

let connector = HttpConnector::new();
let client = hyper::Client::builder()
Expand Down Expand Up @@ -351,7 +353,7 @@ impl Opts {
}
}

fn spawn_server(rt: &mut tokio::runtime::Runtime, opts: &Opts) -> SocketAddr {
fn spawn_server(rt: &tokio::runtime::Runtime, opts: &Opts) -> SocketAddr {
use hyper::service::{make_service_fn, service_fn};
let addr = "127.0.0.1:0".parse().unwrap();

Expand Down
3 changes: 1 addition & 2 deletions benches/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ fn hello_world(b: &mut test::Bencher) {
}))
});

let mut rt = tokio::runtime::Builder::new()
let rt = tokio::runtime::Builder::new_current_thread()
.enable_all()
.basic_scheduler()
.build()
.expect("rt build");
let srv = rt.block_on(async move {
Expand Down
4 changes: 2 additions & 2 deletions benches/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ macro_rules! bench_server {
}))
});

let mut rt = tokio::runtime::Builder::new()
let rt = tokio::runtime::Builder::new_current_thread()
.enable_all()
.basic_scheduler()
.build()
.expect("rt build");

Expand Down Expand Up @@ -185,6 +184,7 @@ fn raw_tcp_throughput_large_payload(b: &mut test::Bencher) {
let mut buf = [0u8; 8192];
while rx.try_recv().is_err() {
let r = sock.read(&mut buf).unwrap();
extern crate test;
if r == 0 {
break;
}
Expand Down
5 changes: 2 additions & 3 deletions examples/single_threaded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ fn main() {
pretty_env_logger::init();

// Configure a runtime that runs everything on the current thread
let mut rt = tokio::runtime::Builder::new()
let rt = tokio::runtime::Builder::new_current_thread()
.enable_all()
.basic_scheduler()
.build()
.expect("build runtime");

// Combine it with a `LocalSet, which means it can spawn !Send futures...
let local = tokio::task::LocalSet::new();
local.block_on(&mut rt, run());
local.block_on(&rt, run());
}

async fn run() {
Expand Down
Loading