Skip to content

Commit

Permalink
stream: add StreamNotifyClose (tokio-rs#4851)
Browse files Browse the repository at this point in the history
  • Loading branch information
aviramha authored and folkertdev committed Apr 20, 2023
1 parent 5cef6eb commit 7b1ae8a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tokio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pin-project-lite = "0.2.0"

# Everything else is optional...
bytes = { version = "1.0.0", optional = true }
mio = { version = "0.8.4", optional = true }
mio = { version = "0.8.6", optional = true }
num_cpus = { version = "1.8.0", optional = true }
parking_lot = { version = "0.12.0", optional = true }

Expand Down
26 changes: 26 additions & 0 deletions tokio/src/io/async_fd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,32 @@ impl<T: AsRawFd> AsyncFd<T> {
self.readiness_mut(Interest::WRITABLE).await
}

/// Waits for the file descriptor to become priority ready, returning a
/// [`AsyncFdReadyGuard`] that must be dropped to resume priority-readiness
/// polling.
///
/// This method takes `&self`, so it is possible to call this method
/// concurrently with other methods on this struct. This method only
/// provides shared access to the inner IO resource when handling the
/// [`AsyncFdReadyGuard`].
#[allow(clippy::needless_lifetimes)] // The lifetime improves rustdoc rendering.
#[cfg(any(target_os = "linux", target_os = "android"))]
pub async fn priority<'a>(&'a self) -> io::Result<AsyncFdReadyGuard<'a, T>> {
self.readiness(Interest::PRIORITY).await
}

/// Waits for the file descriptor to become priority ready, returning a
/// [`AsyncFdReadyMutGuard`] that must be dropped to resume priority-readiness
/// polling.
///
/// This method takes `&mut self`, so it is possible to access the inner IO
/// resource mutably when handling the [`AsyncFdReadyMutGuard`].
#[allow(clippy::needless_lifetimes)] // The lifetime improves rustdoc rendering.
#[cfg(any(target_os = "linux", target_os = "android"))]
pub async fn priority_mut<'a>(&'a mut self) -> io::Result<AsyncFdReadyMutGuard<'a, T>> {
self.readiness_mut(Interest::PRIORITY).await
}

/// Reads or writes from the file descriptor using a user-provided IO operation.
///
/// The `async_io` method is a convenience utility that waits for the file
Expand Down
4 changes: 4 additions & 0 deletions tokio/src/io/interest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ impl Interest {
/// Writable interest includes write-closed events.
pub const WRITABLE: Interest = Interest(mio::Interest::WRITABLE);

/// Returns a `Interest` set representing priority completion interests.
#[cfg(any(target_os = "linux", target_os = "android"))]
pub const PRIORITY: Interest = Interest(mio::Interest::PRIORITY);

/// Returns true if the value includes readable interest.
///
/// # Examples
Expand Down

0 comments on commit 7b1ae8a

Please sign in to comment.