chore(client): re-enable client's custom executor config
This commit is contained in:
@@ -453,16 +453,15 @@ impl Builder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
/// Provide an executor to execute background HTTP2 tasks.
|
/// Provide an executor to execute background HTTP2 tasks.
|
||||||
pub fn executor<E>(&mut self, exec: E) -> &mut Builder
|
pub fn executor<E>(&mut self, exec: E) -> &mut Builder
|
||||||
where
|
where
|
||||||
E: Executor<Box<dyn Future<Item=(), Error=()> + Send>> + Send + Sync + 'static,
|
for<'a> &'a E: tokio_executor::Executor,
|
||||||
|
E: Send + Sync + 'static,
|
||||||
{
|
{
|
||||||
self.exec = Exec::Executor(Arc::new(exec));
|
self.exec = Exec::Executor(Arc::new(exec));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
pub(super) fn h1_writev(&mut self, enabled: bool) -> &mut Builder {
|
pub(super) fn h1_writev(&mut self, enabled: bool) -> &mut Builder {
|
||||||
self.h1_writev = enabled;
|
self.h1_writev = enabled;
|
||||||
|
|||||||
@@ -1011,16 +1011,15 @@ impl Builder {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
/// Provide an executor to execute background `Connection` tasks.
|
/// Provide an executor to execute background `Connection` tasks.
|
||||||
pub fn executor<E>(&mut self, exec: E) -> &mut Self
|
pub fn executor<E>(&mut self, exec: E) -> &mut Self
|
||||||
where
|
where
|
||||||
E: Executor<Box<dyn Future<Item=(), Error=()> + Send>> + Send + Sync + 'static,
|
for<'a> &'a E: tokio_executor::Executor,
|
||||||
|
E: Send + Sync + 'static,
|
||||||
{
|
{
|
||||||
self.conn_builder.executor(exec);
|
self.conn_builder.executor(exec);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
/// Builder a client with this configuration and the default `HttpConnector`.
|
/// Builder a client with this configuration and the default `HttpConnector`.
|
||||||
#[cfg(feature = "runtime")]
|
#[cfg(feature = "runtime")]
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use std::future::Future;
|
|||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use tokio_executor::TypedExecutor;
|
use tokio_executor::{SpawnError, TypedExecutor};
|
||||||
|
|
||||||
use crate::body::Payload;
|
use crate::body::Payload;
|
||||||
use crate::proto::h2::server::H2Stream;
|
use crate::proto::h2::server::H2Stream;
|
||||||
@@ -18,12 +18,27 @@ pub trait NewSvcExec<I, N, S: Service, E, W: Watcher<I, S, E>>: Clone {
|
|||||||
fn execute_new_svc(&mut self, fut: NewSvcTask<I, N, S, E, W>) -> crate::Result<()>;
|
fn execute_new_svc(&mut self, fut: NewSvcTask<I, N, S, E, W>) -> crate::Result<()>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type BoxFuture = Pin<Box<dyn Future<Output=()> + Send>>;
|
||||||
|
|
||||||
|
pub trait SharedExecutor {
|
||||||
|
fn shared_spawn(&self, future: BoxFuture) -> Result<(), SpawnError>;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<E> SharedExecutor for E
|
||||||
|
where
|
||||||
|
for<'a> &'a E: tokio_executor::Executor,
|
||||||
|
{
|
||||||
|
fn shared_spawn(mut self: &Self, future: BoxFuture) -> Result<(), SpawnError> {
|
||||||
|
tokio_executor::Executor::spawn(&mut self, future)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Either the user provides an executor for background tasks, or we use
|
// Either the user provides an executor for background tasks, or we use
|
||||||
// `tokio::spawn`.
|
// `tokio::spawn`.
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub enum Exec {
|
pub enum Exec {
|
||||||
Default,
|
Default,
|
||||||
Executor(Arc<dyn TypedExecutor<Pin<Box<dyn Future<Output=()> + Send>>> + Send + Sync>),
|
Executor(Arc<dyn SharedExecutor + Send + Sync>),
|
||||||
}
|
}
|
||||||
|
|
||||||
// ===== impl Exec =====
|
// ===== impl Exec =====
|
||||||
@@ -73,14 +88,11 @@ impl Exec {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
Exec::Executor(ref e) => {
|
Exec::Executor(ref e) => {
|
||||||
unimplemented!("custom executor exec");
|
e.shared_spawn(Box::pin(fut))
|
||||||
/* XXX: needs mut
|
|
||||||
e.spawn(Box::pin(fut))
|
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
warn!("executor error: {:?}", err);
|
warn!("executor error: {:?}", err);
|
||||||
crate::Error::new_execute("custom executor failed")
|
crate::Error::new_execute("custom executor failed")
|
||||||
})
|
})
|
||||||
*/
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user