feat: add transmit to UdpPoller::poll_writable

This commit is contained in:
dignifiedquire
2025-05-20 16:03:44 +02:00
parent a8cca03aa9
commit 3b8540bfc0
2 changed files with 11 additions and 3 deletions
+1 -1
View File
@@ -1057,7 +1057,7 @@ impl State {
}
};
if self.io_poller.as_mut().poll_writable(cx)?.is_pending() {
if self.io_poller.as_mut().poll_writable(cx, &t)?.is_pending() {
// Retry after a future wakeup
self.buffered_transmit = Some(t);
return Ok(false);
+10 -2
View File
@@ -98,7 +98,11 @@ pub trait UdpPoller: Send + Sync + Debug + 'static {
/// register the task associated with `cx` to be woken when a send should be attempted
/// again. Unlike in [`Future::poll`], a [`UdpPoller`] may be reused indefinitely no matter how
/// many times `poll_writable` returns [`Poll::Ready`].
fn poll_writable(self: Pin<&mut Self>, cx: &mut Context) -> Poll<io::Result<()>>;
fn poll_writable(
self: Pin<&mut Self>,
cx: &mut Context,
t: &proto::Transmit,
) -> Poll<io::Result<()>>;
}
pin_project_lite::pin_project! {
@@ -133,7 +137,11 @@ where
MakeFut: Fn() -> Fut + Send + Sync + 'static,
Fut: Future<Output = io::Result<()>> + Send + Sync + 'static,
{
fn poll_writable(self: Pin<&mut Self>, cx: &mut Context) -> Poll<io::Result<()>> {
fn poll_writable(
self: Pin<&mut Self>,
cx: &mut Context,
_t: &proto::Transmit,
) -> Poll<io::Result<()>> {
let mut this = self.project();
if this.fut.is_none() {
this.fut.set(Some((this.make_fut)()));