From dde38bbe064e2676622316170ad2c8456a6fc8e1 Mon Sep 17 00:00:00 2001 From: Juan Aguilar Santillana Date: Mon, 2 Jan 2023 14:36:46 +0100 Subject: [PATCH] remove unnecessary Pin in poll_recv calls (#475) --- actix-rt/src/arbiter.rs | 2 +- actix-rt/src/system.rs | 2 +- actix-server/src/server.rs | 2 +- actix-server/src/signals.rs | 2 +- actix-server/src/worker.rs | 8 +++----- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/actix-rt/src/arbiter.rs b/actix-rt/src/arbiter.rs index 4c9a588e..a84e25ea 100644 --- a/actix-rt/src/arbiter.rs +++ b/actix-rt/src/arbiter.rs @@ -303,7 +303,7 @@ impl Future for ArbiterRunner { fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { // process all items currently buffered in channel loop { - match ready!(Pin::new(&mut self.rx).poll_recv(cx)) { + match ready!(self.rx.poll_recv(cx)) { // channel closed; no more messages can be received None => return Poll::Ready(()), diff --git a/actix-rt/src/system.rs b/actix-rt/src/system.rs index f3a5a4d8..d0494a22 100644 --- a/actix-rt/src/system.rs +++ b/actix-rt/src/system.rs @@ -292,7 +292,7 @@ impl Future for SystemController { fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { // process all items currently buffered in channel loop { - match ready!(Pin::new(&mut self.cmd_rx).poll_recv(cx)) { + match ready!(self.cmd_rx.poll_recv(cx)) { // channel closed; no more messages can be received None => return Poll::Ready(()), diff --git a/actix-server/src/server.rs b/actix-server/src/server.rs index a7bd5b53..7e092e2b 100644 --- a/actix-server/src/server.rs +++ b/actix-server/src/server.rs @@ -363,6 +363,6 @@ impl Stream for ServerEventMultiplexer { } } - Pin::new(&mut this.cmd_rx).poll_recv(cx) + this.cmd_rx.poll_recv(cx) } } diff --git a/actix-server/src/signals.rs b/actix-server/src/signals.rs index 6a212d83..2b01f015 100644 --- a/actix-server/src/signals.rs +++ b/actix-server/src/signals.rs @@ -96,7 +96,7 @@ impl Future for Signals { #[cfg(unix)] { for (sig, fut) in self.signals.iter_mut() { - if Pin::new(fut).poll_recv(cx).is_ready() { + if fut.poll_recv(cx).is_ready() { trace!("{} received", sig); return Poll::Ready(*sig); } diff --git a/actix-server/src/worker.rs b/actix-server/src/worker.rs index 35ba1366..2765ae4a 100644 --- a/actix-server/src/worker.rs +++ b/actix-server/src/worker.rs @@ -585,9 +585,7 @@ impl Future for ServerWorker { let this = self.as_mut().get_mut(); // `StopWorker` message handler - if let Poll::Ready(Some(Stop { graceful, tx })) = - Pin::new(&mut this.stop_rx).poll_recv(cx) - { + if let Poll::Ready(Some(Stop { graceful, tx })) = this.stop_rx.poll_recv(cx) { let num = this.counter.total(); if num == 0 { info!("shutting down idle worker"); @@ -649,7 +647,7 @@ impl Future for ServerWorker { } WorkerState::Shutdown(ref mut shutdown) => { // drop all pending connections in rx channel. - while let Poll::Ready(Some(conn)) = Pin::new(&mut this.conn_rx).poll_recv(cx) { + while let Poll::Ready(Some(conn)) = this.conn_rx.poll_recv(cx) { // WorkerCounterGuard is needed as Accept thread has incremented counter. // It's guard's job to decrement the counter together with drop of Conn. let guard = this.counter.guard(); @@ -696,7 +694,7 @@ impl Future for ServerWorker { } // handle incoming io stream - match ready!(Pin::new(&mut this.conn_rx).poll_recv(cx)) { + match ready!(this.conn_rx.poll_recv(cx)) { Some(msg) => { let guard = this.counter.guard(); let _ = this.services[msg.token].service.call((guard, msg.io));