Skip to content

Commit

Permalink
Merge pull request hyperium#1502 from hyperium/tokio-timer
Browse files Browse the repository at this point in the history
refactor(lib): change from futures-timer to tokio-timer
  • Loading branch information
seanmonstar authored May 1, 2018
2 parents 5e3b43a + 7a7453b commit 792b55f
Show file tree
Hide file tree
Showing 9 changed files with 248 additions and 228 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ cache:
script:
- ./.travis/readme.py
- cargo build $FEATURES
- 'if [ "$BUILD_ONLY" != "1" ]; then RUST_LOG=hyper cargo test $FEATURES; fi'
- 'if [ "$BUILD_ONLY" != "1" ]; then RUST_LOG=hyper cargo test $FEATURES -- --test-threads=1; fi'
- 'if [ $TRAVIS_RUST_VERSION = nightly ]; then for f in ./benches/*.rs; do cargo test --bench $(basename $f .rs) $FEATURES; done; fi'

addons:
Expand Down
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ include = [
bytes = "0.4.4"
futures = "0.1.21"
futures-cpupool = { version = "0.1.6", optional = true }
futures-timer = "0.1.0"
http = "0.1.5"
httparse = "1.0"
h2 = "0.1.5"
Expand All @@ -37,9 +36,11 @@ tokio-executor = { version = "0.1.0", optional = true }
tokio-io = "0.1"
tokio-reactor = { version = "0.1", optional = true }
tokio-tcp = { version = "0.1", optional = true }
tokio-timer = { version = "0.2", optional = true }
want = "0.0.4"

[dev-dependencies]
futures-timer = "0.1"
num_cpus = "1.0"
pretty_env_logger = "0.2.0"
spmc = "0.2"
Expand All @@ -55,6 +56,7 @@ runtime = [
"tokio-executor",
"tokio-reactor",
"tokio-tcp",
"tokio-timer",
]

[[example]]
Expand Down
18 changes: 3 additions & 15 deletions src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,6 @@ where C: Connect + Sync + 'static,

/// Send a constructed Request using this Client.
pub fn request(&self, mut req: Request<B>) -> FutureResponse {
// TODO(0.12): do this at construction time.
//
// It cannot be done in the constructor because the Client::configured
// does not have `B: 'static` bounds, which are required to spawn
// the interval. In 0.12, add a static bounds to the constructor,
// and move this.
self.schedule_pool_timer();

match req.version() {
Version::HTTP_10 |
Version::HTTP_11 => (),
Expand Down Expand Up @@ -302,7 +294,7 @@ where C: Connect + Sync + 'static,
// for a new request to start.
//
// It won't be ready if there is a body to stream.
if ver == Ver::Http2 || pooled.is_ready() {
if ver == Ver::Http2 || !pooled.is_pool_enabled() || pooled.is_ready() {
drop(pooled);
} else if !res.body().is_empty() {
let (delayed_tx, delayed_rx) = oneshot::channel();
Expand Down Expand Up @@ -336,10 +328,6 @@ where C: Connect + Sync + 'static,

Box::new(resp)
}

fn schedule_pool_timer(&self) {
self.pool.spawn_expired_interval(&self.executor);
}
}

impl<C, B> Clone for Client<C, B> {
Expand Down Expand Up @@ -474,7 +462,7 @@ impl<B: Payload + 'static> PoolClient<B> {

impl<B> Poolable for PoolClient<B>
where
B: 'static,
B: Send + 'static,
{
fn is_open(&self) -> bool {
match self.tx {
Expand Down Expand Up @@ -700,7 +688,7 @@ impl Builder {
executor: self.exec.clone(),
h1_writev: self.h1_writev,
h1_title_case_headers: self.h1_title_case_headers,
pool: Pool::new(self.keep_alive, self.keep_alive_timeout),
pool: Pool::new(self.keep_alive, self.keep_alive_timeout, &self.exec),
retry_canceled_requests: self.retry_canceled_requests,
set_host: self.set_host,
ver: self.ver,
Expand Down
Loading

0 comments on commit 792b55f

Please sign in to comment.