allow dead code on signals

This commit is contained in:
Rob Ede 2021-11-03 17:22:27 +00:00
parent 3ba69afe9f
commit a12871cebc
3 changed files with 17 additions and 16 deletions

View File

@ -7,16 +7,16 @@ use crate::server::ServerCommand;
/// Server handle. /// Server handle.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct ServerHandle { pub struct ServerHandle {
tx_cmd: UnboundedSender<ServerCommand>, cmd_tx: UnboundedSender<ServerCommand>,
} }
impl ServerHandle { impl ServerHandle {
pub(crate) fn new(tx_cmd: UnboundedSender<ServerCommand>) -> Self { pub(crate) fn new(cmd_tx: UnboundedSender<ServerCommand>) -> Self {
ServerHandle { tx_cmd } ServerHandle { cmd_tx }
} }
pub(crate) fn worker_faulted(&self, idx: usize) { pub(crate) fn worker_faulted(&self, idx: usize) {
let _ = self.tx_cmd.send(ServerCommand::WorkerFaulted(idx)); let _ = self.cmd_tx.send(ServerCommand::WorkerFaulted(idx));
} }
/// Pause accepting incoming connections. /// Pause accepting incoming connections.
@ -24,7 +24,7 @@ impl ServerHandle {
/// May drop socket pending connection. All open connections remain active. /// May drop socket pending connection. All open connections remain active.
pub fn pause(&self) -> impl Future<Output = ()> { pub fn pause(&self) -> impl Future<Output = ()> {
let (tx, rx) = oneshot::channel(); let (tx, rx) = oneshot::channel();
let _ = self.tx_cmd.send(ServerCommand::Pause(tx)); let _ = self.cmd_tx.send(ServerCommand::Pause(tx));
async { async {
let _ = rx.await; let _ = rx.await;
} }
@ -33,7 +33,7 @@ impl ServerHandle {
/// Resume accepting incoming connections. /// Resume accepting incoming connections.
pub fn resume(&self) -> impl Future<Output = ()> { pub fn resume(&self) -> impl Future<Output = ()> {
let (tx, rx) = oneshot::channel(); let (tx, rx) = oneshot::channel();
let _ = self.tx_cmd.send(ServerCommand::Resume(tx)); let _ = self.cmd_tx.send(ServerCommand::Resume(tx));
async { async {
let _ = rx.await; let _ = rx.await;
} }
@ -42,7 +42,7 @@ impl ServerHandle {
/// Stop incoming connection processing, stop all workers and exit. /// Stop incoming connection processing, stop all workers and exit.
pub fn stop(&self, graceful: bool) -> impl Future<Output = ()> { pub fn stop(&self, graceful: bool) -> impl Future<Output = ()> {
let (tx, rx) = oneshot::channel(); let (tx, rx) = oneshot::channel();
let _ = self.tx_cmd.send(ServerCommand::Stop { let _ = self.cmd_tx.send(ServerCommand::Stop {
graceful, graceful,
completion: Some(tx), completion: Some(tx),
}); });

View File

@ -10,6 +10,7 @@ use log::trace;
/// Types of process signals. /// Types of process signals.
// #[allow(dead_code)] // #[allow(dead_code)]
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq)]
#[allow(dead_code)] // variants are never constructed on non-unix
pub(crate) enum Signal { pub(crate) enum Signal {
/// `SIGINT` /// `SIGINT`
Int, Int,

View File

@ -43,20 +43,20 @@ pub(crate) struct Conn {
pub token: usize, pub token: usize,
} }
/// /// Create accept and server worker handles.
fn handle_pair( fn handle_pair(
idx: usize, idx: usize,
tx_conn: UnboundedSender<Conn>, conn_tx: UnboundedSender<Conn>,
tx_stop: UnboundedSender<Stop>, stop_tx: UnboundedSender<Stop>,
counter: Counter, counter: Counter,
) -> (WorkerHandleAccept, WorkerHandleServer) { ) -> (WorkerHandleAccept, WorkerHandleServer) {
let accept = WorkerHandleAccept { let accept = WorkerHandleAccept {
idx, idx,
tx_conn, conn_tx,
counter, counter,
}; };
let server = WorkerHandleServer { idx, tx_stop }; let server = WorkerHandleServer { idx, stop_tx };
(accept, server) (accept, server)
} }
@ -158,7 +158,7 @@ impl Drop for WorkerCounterGuard {
/// Held by [Accept](crate::accept::Accept). /// Held by [Accept](crate::accept::Accept).
pub(crate) struct WorkerHandleAccept { pub(crate) struct WorkerHandleAccept {
idx: usize, idx: usize,
tx_conn: UnboundedSender<Conn>, conn_tx: UnboundedSender<Conn>,
counter: Counter, counter: Counter,
} }
@ -170,7 +170,7 @@ impl WorkerHandleAccept {
#[inline(always)] #[inline(always)]
pub(crate) fn send(&self, conn: Conn) -> Result<(), Conn> { pub(crate) fn send(&self, conn: Conn) -> Result<(), Conn> {
self.tx_conn.send(conn).map_err(|msg| msg.0) self.conn_tx.send(conn).map_err(|msg| msg.0)
} }
#[inline(always)] #[inline(always)]
@ -185,13 +185,13 @@ impl WorkerHandleAccept {
#[derive(Debug)] #[derive(Debug)]
pub(crate) struct WorkerHandleServer { pub(crate) struct WorkerHandleServer {
pub(crate) idx: usize, pub(crate) idx: usize,
tx_stop: UnboundedSender<Stop>, stop_tx: UnboundedSender<Stop>,
} }
impl WorkerHandleServer { impl WorkerHandleServer {
pub(crate) fn stop(&self, graceful: bool) -> oneshot::Receiver<bool> { pub(crate) fn stop(&self, graceful: bool) -> oneshot::Receiver<bool> {
let (tx, rx) = oneshot::channel(); let (tx, rx) = oneshot::channel();
let _ = self.tx_stop.send(Stop { graceful, tx }); let _ = self.stop_tx.send(Stop { graceful, tx });
rx rx
} }
} }