Skip to content

Commit 2c0e602

Browse files
committed
Revert "Do not use tokio::select! for race2"
This reverts commit 95ce856.
1 parent 01588c0 commit 2c0e602

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

src/server.rs

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -464,25 +464,10 @@ impl<T> Future for UnwrapToPending<T> {
464464
}
465465

466466
pub(crate) async fn race2<T, A: Future<Output = T>, B: Future<Output = T>>(f1: A, f2: B) -> T {
467-
// Pin the futures on the stack for polling
468-
let mut f1 = std::pin::pin!(f1);
469-
let mut f2 = std::pin::pin!(f2);
470-
471-
// Create a future that resolves when either f1 or f2 completes
472-
std::future::poll_fn(|cx| {
473-
// Poll both futures
474-
match f1.as_mut().poll(cx) {
475-
Poll::Ready(result) => return Poll::Ready(result),
476-
Poll::Pending => {}
477-
}
478-
match f2.as_mut().poll(cx) {
479-
Poll::Ready(result) => return Poll::Ready(result),
480-
Poll::Pending => {}
481-
}
482-
// If neither is ready, yield back to the executor
483-
Poll::Pending
484-
})
485-
.await
467+
tokio::select! {
468+
x = f1 => x,
469+
x = f2 => x,
470+
}
486471
}
487472

488473
/// Run a server loop, invoking a handler callback for each request.

0 commit comments

Comments
 (0)