mirror of https://github.com/fafhrd91/actix-net
Remove Future impl for ServerHandle
This commit is contained in:
parent
8891eb02a9
commit
f0cb449d99
|
@ -127,10 +127,6 @@ impl Server {
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ServerCommand::Notify(tx) => {
|
|
||||||
self.notify.push(tx);
|
|
||||||
None
|
|
||||||
}
|
|
||||||
ServerCommand::Stop {
|
ServerCommand::Stop {
|
||||||
graceful,
|
graceful,
|
||||||
completion,
|
completion,
|
||||||
|
@ -272,19 +268,14 @@ pub(crate) enum ServerCommand {
|
||||||
graceful: bool,
|
graceful: bool,
|
||||||
completion: Option<oneshot::Sender<()>>,
|
completion: Option<oneshot::Sender<()>>,
|
||||||
},
|
},
|
||||||
/// Notify of server stop
|
|
||||||
Notify(oneshot::Sender<()>),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct ServerHandle(
|
pub struct ServerHandle(UnboundedSender<ServerCommand>);
|
||||||
UnboundedSender<ServerCommand>,
|
|
||||||
Option<oneshot::Receiver<()>>,
|
|
||||||
);
|
|
||||||
|
|
||||||
impl ServerHandle {
|
impl ServerHandle {
|
||||||
pub(crate) fn new(tx: UnboundedSender<ServerCommand>) -> Self {
|
pub(crate) fn new(tx: UnboundedSender<ServerCommand>) -> Self {
|
||||||
ServerHandle(tx, None)
|
ServerHandle(tx)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn worker_faulted(&self, idx: usize) {
|
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<Self::Output> {
|
|
||||||
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(()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue