diff options
author | masnagam <masnagam@gmail.com> | 2020-11-17 02:51:06 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-16 09:51:06 -0800 |
commit | 4e39c9b818eb8af064bb9f45f47e3cfc6593de95 (patch) | |
tree | 2222dd2f8638fb64f228badef84814d2f4079a82 /tokio/src | |
parent | 97c2c4203cd7c42960cac895987c43a17dff052e (diff) |
net: restore TcpStream::{poll_read_ready, poll_write_ready} (#2743)
Diffstat (limited to 'tokio/src')
-rw-r--r-- | tokio/src/net/tcp/stream.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tokio/src/net/tcp/stream.rs b/tokio/src/net/tcp/stream.rs index 2ac37a2b..8a157e1c 100644 --- a/tokio/src/net/tcp/stream.rs +++ b/tokio/src/net/tcp/stream.rs @@ -356,6 +356,17 @@ impl TcpStream { Ok(()) } + /// Polls for read readiness. + /// + /// This function is intended for cases where creating and pinning a future + /// via [`readable`] is not feasible. Where possible, using [`readable`] is + /// preferred, as this supports polling from multiple tasks at once. + /// + /// [`readable`]: method@Self::readable + pub fn poll_read_ready(&self, cx: &mut Context<'_>) -> Poll<io::Result<()>> { + self.io.registration().poll_read_ready(cx).map_ok(|_| ()) + } + /// Try to read data from the stream into the provided buffer, returning how /// many bytes were read. /// @@ -467,6 +478,17 @@ impl TcpStream { Ok(()) } + /// Polls for write readiness. + /// + /// This function is intended for cases where creating and pinning a future + /// via [`writable`] is not feasible. Where possible, using [`writable`] is + /// preferred, as this supports polling from multiple tasks at once. + /// + /// [`writable`]: method@Self::writable + pub fn poll_write_ready(&self, cx: &mut Context<'_>) -> Poll<io::Result<()>> { + self.io.registration().poll_write_ready(cx).map_ok(|_| ()) + } + /// Try to write a buffer to the stream, returning how many bytes were /// written. /// |