From a434a3de71a9483e0e7f5f446718e4aa702cb17b Mon Sep 17 00:00:00 2001 From: nils <48135649+Nilstrieb@users.noreply.github.com> Date: Tue, 7 Mar 2023 15:50:27 +0100 Subject: [PATCH] loop --- hyper/src/common/exec.rs | 2 +- hyper/src/server/server.rs | 35 +++++++++++------------------------ 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/hyper/src/common/exec.rs b/hyper/src/common/exec.rs index a100aef..9432afa 100644 --- a/hyper/src/common/exec.rs +++ b/hyper/src/common/exec.rs @@ -18,7 +18,7 @@ pub trait ConnStreamExec: Clone { fn execute_h2stream(&mut self, fut: H2Stream); } #[cfg(all(feature = "server", any(feature = "http1", feature = "http2")))] -pub trait NewSvcExec, E, W: Watcher>: Clone { +pub trait NewSvcExec>: Clone { fn execute_new_svc(&mut self, fut: NewSvcTask); } pub(crate) type BoxSendFuture = Pin + Send>>; diff --git a/hyper/src/server/server.rs b/hyper/src/server/server.rs index de00c82..0060d15 100644 --- a/hyper/src/server/server.rs +++ b/hyper/src/server/server.rs @@ -12,23 +12,11 @@ use pin_project_lite::pin_project; use std::error::Error as StdError; #[cfg(feature = "tcp")] use tokio::io::{AsyncRead, AsyncWrite}; -pin_project! { - #[doc = - " A listening HTTP server that accepts connections in both HTTP1 and HTTP2 by default."] - #[doc = ""] #[doc = - " `Server` is a `Future` mapping a bound listener with a set of service"] #[doc = - " handlers. It is built using the [`Builder`](Builder), and the future"] #[doc = - " completes when the server has been shutdown. It should be run by an"] #[doc = - " `Executor`."] - - pub struct Server < I, S, E = Exec > { - - #[pin] incoming : I, - make_service : S, - protocol : Http_ < E >, - } +pub struct Server { + incoming: I, + make_service: S, + protocol: E, } - #[derive(Debug)] #[cfg_attr(docsrs, doc(cfg(any(feature = "http1", feature = "http2"))))] pub struct Builder { @@ -52,25 +40,24 @@ impl Server { } } - #[cfg_attr(docsrs, doc(cfg(any(feature = "http1", feature = "http2"))))] impl Future for Server where I: Accept, IE: Into>, - IO: AsyncRead + AsyncWrite + Unpin + Send + 'static, S: MakeServiceRef, - S::Error: Into>, - B: HttpBody + 'static, - B::Error: Into>, - E: ConnStreamExec<>::Future, B>, E: NewSvcExec, { - type Output = crate::Result<()>; + type Output = (); fn poll(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll { loop { let fut = NewSvcTask::new(NoopWatcher); - self.as_mut().project().protocol.exec.execute_new_svc(fut); + unsafe { + self.as_mut() + .get_unchecked_mut() + .protocol + .execute_new_svc(fut); + } } } }