Skip to content

Commit

Permalink
remove unnecessary Pin in poll_recv calls (#475)
Browse files Browse the repository at this point in the history
  • Loading branch information
zzau13 authored Jan 2, 2023
1 parent d973d59 commit dde38bb
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion actix-rt/src/arbiter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ impl Future for ArbiterRunner {
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
// 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(()),

Expand Down
2 changes: 1 addition & 1 deletion actix-rt/src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ impl Future for SystemController {
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
// 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(()),

Expand Down
2 changes: 1 addition & 1 deletion actix-server/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,6 @@ impl Stream for ServerEventMultiplexer {
}
}

Pin::new(&mut this.cmd_rx).poll_recv(cx)
this.cmd_rx.poll_recv(cx)
}
}
2 changes: 1 addition & 1 deletion actix-server/src/signals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
8 changes: 3 additions & 5 deletions actix-server/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit dde38bb

Please sign in to comment.