Implement flush for TcpSocket

This commit is contained in:
kbleeke 2023-02-22 13:57:40 +01:00
parent b05cd77a62
commit f1a4db44c4

View File

@ -254,10 +254,19 @@ impl<'d> TcpIo<'d> {
.await .await
} }
#[allow(unused)]
async fn flush(&mut self) -> Result<(), Error> { async fn flush(&mut self) -> Result<(), Error> {
poll_fn(move |_| { poll_fn(move |cx| {
Poll::Ready(Ok(())) // TODO: Is there a better implementation for this? self.with_mut(|s, _| {
// If there are outstanding send operations, register for wake up and wait
// smoltcp issues wake-ups when octets are dequeued from the send buffer
if s.send_queue() > 0 {
s.register_send_waker(cx.waker());
Poll::Pending
// No outstanding sends, socket is flushed
} else {
Poll::Ready(Ok(()))
}
})
}) })
.await .await
} }