diff --git a/src/client/legacy.rs b/src/client/legacy.rs index 4b899b3..f719dc1 100644 --- a/src/client/legacy.rs +++ b/src/client/legacy.rs @@ -1430,15 +1430,16 @@ impl Builder { B: Body + Send, B::Data: Send, { + let exec = self.exec.clone(); Client { config: self.client_config, - exec: self.exec.clone(), + exec: exec.clone(), #[cfg(feature = "http1")] h1_builder: self.h1_builder.clone(), #[cfg(feature = "http2")] h2_builder: self.h2_builder.clone(), connector, - pool: pool::Pool::new(self.pool_config, &self.exec), + pool: pool::Pool::new(self.pool_config, exec), } } } diff --git a/src/client/pool.rs b/src/client/pool.rs index 9d56494..70e7959 100644 --- a/src/client/pool.rs +++ b/src/client/pool.rs @@ -20,7 +20,7 @@ use tokio::time::{Duration, Instant, Interval}; use futures_channel::oneshot; use tracing::{debug, trace}; -use crate::common::{exec::Exec, ready}; +use crate::common::{exec, exec::Exec, ready}; // FIXME: allow() required due to `impl Trait` leaking types to this lint #[allow(missing_debug_implementations)] @@ -121,7 +121,11 @@ impl Config { } impl Pool { - pub fn new(config: Config, __exec: &Exec) -> Pool { + pub fn new(config: Config, executor: E) -> Pool + where + E: hyper::rt::Executor + Send + Sync + Clone + 'static, + { + let exec = Exec::new(executor); let inner = if config.is_enabled() { Some(Arc::new(Mutex::new(PoolInner { connecting: HashSet::new(), @@ -131,7 +135,7 @@ impl Pool { max_idle_per_host: config.max_idle_per_host, waiters: HashMap::new(), #[cfg(feature = "runtime")] - exec: __exec.clone(), + exec, timeout: config.idle_timeout, }))) } else { @@ -830,7 +834,7 @@ mod tests { use std::time::Duration; use super::{Connecting, Key, Pool, Poolable, Reservation, WeakOpt}; - use crate::common::exec::Exec; + use crate::rt::tokio_executor::TokioExecutor; #[derive(Clone, Debug, PartialEq, Eq, Hash)] struct KeyImpl(http::uri::Scheme, http::uri::Authority); @@ -876,7 +880,7 @@ mod tests { idle_timeout: Some(Duration::from_millis(100)), max_idle_per_host: max_idle, }, - &Exec::Default, + TokioExecutor::new(), ); pool.no_timer(); pool @@ -977,7 +981,7 @@ mod tests { idle_timeout: Some(Duration::from_millis(10)), max_idle_per_host: std::usize::MAX, }, - &Exec::Default, + TokioExecutor::new(), ); let key = host_key("foo");