summaryrefslogtreecommitdiffstats
path: root/tokio/src/signal
diff options
context:
space:
mode:
authorCarl Lerche <me@carllerche.com>2020-11-12 20:07:43 -0800
committerGitHub <noreply@github.com>2020-11-12 20:07:43 -0800
commit02b1117dca1c1e1fcc700bff4d6a93c33bfbc7d8 (patch)
tree95788ea2d89de4af6021befa70a3f5d80034578a /tokio/src/signal
parent685da8dadd8821d1053ce7ecaf01ab5ee231bef9 (diff)
net: add TcpStream::ready and non-blocking ops (#3130)
Adds function to await for readiness on the TcpStream and non-blocking read/write functions. `async fn TcpStream::ready(Interest)` waits for socket readiness satisfying **any** of the specified interest. There are also two shorthand functions, `readable()` and `writable()`. Once the stream is in a ready state, the caller may perform non-blocking operations on it using `try_read()` and `try_write()`. These function return `WouldBlock` if the stream is not, in fact, ready. The await readiness function are similar to `AsyncFd`, but do not require a guard. The guard in `AsyncFd` protect against a potential race between receiving the readiness notification and clearing it. The guard is needed as Tokio does not control the operations. With `TcpStream`, the `try_read()` and `try_write()` function handle clearing stream readiness as needed. This also exposes `Interest` and `Ready`, both defined in Tokio as wrappers for Mio types. These types will also be useful for fixing #3072 . Other I/O types, such as `TcpListener`, `UdpSocket`, `Unix*` should get similar functions, but this is left for later PRs. Refs: #3130
Diffstat (limited to 'tokio/src/signal')
-rw-r--r--tokio/src/signal/unix/driver.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/tokio/src/signal/unix/driver.rs b/tokio/src/signal/unix/driver.rs
index 323bb9df..315f3bd5 100644
--- a/tokio/src/signal/unix/driver.rs
+++ b/tokio/src/signal/unix/driver.rs
@@ -2,8 +2,8 @@
//! Signal driver
-use crate::io::driver::Driver as IoDriver;
-use crate::io::{Interest, PollEvented};
+use crate::io::driver::{Driver as IoDriver, Interest};
+use crate::io::PollEvented;
use crate::park::Park;
use crate::signal::registry::globals;