Move serve implementation out of WithGracefulShutdown

This commit is contained in:
Jonas Platte
2025-04-30 14:19:15 +02:00
parent 6587b65393
commit 085be6970b
+2 -11
View File
@@ -267,14 +267,14 @@ where
fn into_future(self) -> Self::IntoFuture { fn into_future(self) -> Self::IntoFuture {
private::ServeFuture(Box::pin(async move { private::ServeFuture(Box::pin(async move {
self.run().await; do_serve(self.listener, self.make_service, self.signal).await;
Ok(()) Ok(())
})) }))
} }
} }
#[cfg(all(feature = "tokio", any(feature = "http1", feature = "http2")))] #[cfg(all(feature = "tokio", any(feature = "http1", feature = "http2")))]
impl<L, M, S, F> WithGracefulShutdown<L, M, S, F> async fn do_serve<L, M, F, S>(mut listener: L, mut make_service: M, signal: F)
where where
L: Listener, L: Listener,
L::Addr: Debug, L::Addr: Debug,
@@ -284,14 +284,6 @@ where
S::Future: Send, S::Future: Send,
F: Future<Output = ()> + Send + 'static, F: Future<Output = ()> + Send + 'static,
{ {
async fn run(self) {
let Self {
mut listener,
mut make_service,
signal,
_marker: _,
} = self;
let (signal_tx, signal_rx) = watch::channel(()); let (signal_tx, signal_rx) = watch::channel(());
tokio::spawn(async move { tokio::spawn(async move {
signal.await; signal.await;
@@ -371,7 +363,6 @@ where
); );
close_tx.closed().await; close_tx.closed().await;
} }
}
/// An incoming stream. /// An incoming stream.
/// ///