Skip to content

Commit 4f8a0f1

Browse files
gretchenfrageRalith
authored andcommitted
refactor(quinn): Remove some usage of execute_poll
This commit makes there be fewer places where SendStream::execute_poll is called directly. AsyncWrite implementations now go through poll_write, and poll_write now goes through the write future. This means that execute_poll is now only called directly from write and write_chunks.
1 parent 176e84c commit 4f8a0f1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

quinn/src/send_stream.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::{
22
future::{Future, poll_fn},
33
io,
4-
pin::Pin,
4+
pin::{Pin, pin},
55
task::{Context, Poll},
66
};
77

@@ -248,7 +248,7 @@ impl SendStream {
248248
cx: &mut Context,
249249
buf: &[u8],
250250
) -> Poll<Result<usize, WriteError>> {
251-
self.get_mut().execute_poll(cx, |stream| stream.write(buf))
251+
pin!(self.get_mut().write(buf)).as_mut().poll(cx)
252252
}
253253
}
254254

@@ -274,7 +274,7 @@ fn send_stream_stopped(
274274
#[cfg(feature = "futures-io")]
275275
impl futures_io::AsyncWrite for SendStream {
276276
fn poll_write(self: Pin<&mut Self>, cx: &mut Context, buf: &[u8]) -> Poll<io::Result<usize>> {
277-
Self::execute_poll(self.get_mut(), cx, |stream| stream.write(buf)).map_err(Into::into)
277+
self.poll_write(cx, buf).map_err(Into::into)
278278
}
279279

280280
fn poll_flush(self: Pin<&mut Self>, _cx: &mut Context) -> Poll<io::Result<()>> {
@@ -292,7 +292,7 @@ impl tokio::io::AsyncWrite for SendStream {
292292
cx: &mut Context<'_>,
293293
buf: &[u8],
294294
) -> Poll<io::Result<usize>> {
295-
Self::execute_poll(self.get_mut(), cx, |stream| stream.write(buf)).map_err(Into::into)
295+
self.poll_write(cx, buf).map_err(Into::into)
296296
}
297297

298298
fn poll_flush(self: Pin<&mut Self>, _cx: &mut Context) -> Poll<io::Result<()>> {

0 commit comments

Comments
 (0)