From f0cb449d9993bd6fbaff01b6cb862bfb3276539a Mon Sep 17 00:00:00 2001 From: fakeshadow <24548779@qq.com> Date: Mon, 12 Apr 2021 15:06:31 +0800 Subject: [PATCH] Remove Future impl for ServerHandle --- actix-server/src/server.rs | 39 +++----------------------------------- 1 file changed, 3 insertions(+), 36 deletions(-) diff --git a/actix-server/src/server.rs b/actix-server/src/server.rs index f7140079..ba569430 100644 --- a/actix-server/src/server.rs +++ b/actix-server/src/server.rs @@ -127,10 +127,6 @@ impl Server { _ => None, } } - ServerCommand::Notify(tx) => { - self.notify.push(tx); - None - } ServerCommand::Stop { graceful, completion, @@ -272,19 +268,14 @@ pub(crate) enum ServerCommand { graceful: bool, completion: Option>, }, - /// Notify of server stop - Notify(oneshot::Sender<()>), } -#[derive(Debug)] -pub struct ServerHandle( - UnboundedSender, - Option>, -); +#[derive(Clone, Debug)] +pub struct ServerHandle(UnboundedSender); impl ServerHandle { pub(crate) fn new(tx: UnboundedSender) -> Self { - ServerHandle(tx, None) + ServerHandle(tx) } pub(crate) fn worker_faulted(&self, idx: usize) { @@ -326,27 +317,3 @@ impl ServerHandle { } } } - -impl Clone for ServerHandle { - fn clone(&self) -> Self { - Self(self.0.clone(), None) - } -} - -impl Future for ServerHandle { - type Output = io::Result<()>; - - fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { - let this = self.get_mut(); - - if this.1.is_none() { - let (tx, rx) = oneshot::channel(); - if this.0.send(ServerCommand::Notify(tx)).is_err() { - return Poll::Ready(Ok(())); - } - this.1 = Some(rx); - } - - Pin::new(this.1.as_mut().unwrap()).poll(cx).map(|_| Ok(())) - } -}