From c63ee40879a066ef462d9ea9c9172d459e1c1081 Mon Sep 17 00:00:00 2001 From: Noah Kennedy Date: Fri, 20 Oct 2023 14:18:03 -0500 Subject: [PATCH] change names and add docsrs stuff --- tokio/src/io/async_fd.rs | 9 ++++++++- tokio/src/net/tcp/listener.rs | 12 +++++++++++- tokio/src/net/unix/listener.rs | 9 ++++++++- tokio/tests/epollexclusive.rs | 2 +- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/tokio/src/io/async_fd.rs b/tokio/src/io/async_fd.rs index 6f54d6387..b1dbfedf7 100644 --- a/tokio/src/io/async_fd.rs +++ b/tokio/src/io/async_fd.rs @@ -246,9 +246,16 @@ impl AsyncFd { /// Create a new AsyncFd with the provided raw epoll flags for registration. /// /// These flags replace any epoll flags would normally set when registering the fd. + /// + /// **Note**: This is an [unstable API][unstable]. The public API of this may break in 1.x + /// releases. + /// See [the documentation on unstable features][unstable] for details. + /// + /// [unstable]: crate#unstable-features #[track_caller] #[cfg(all(target_os = "linux", tokio_unstable))] - pub fn with_flags(inner: T, flags: u32) -> io::Result + #[cfg_attr(docsrs, doc(cfg(tokio_unstable)), doc(cfg(target_os = "linux")))] + pub fn with_epoll_flags(inner: T, flags: u32) -> io::Result where T: AsRawFd, { diff --git a/tokio/src/net/tcp/listener.rs b/tokio/src/net/tcp/listener.rs index 0c344dd1a..f727d7a37 100644 --- a/tokio/src/net/tcp/listener.rs +++ b/tokio/src/net/tcp/listener.rs @@ -243,9 +243,19 @@ impl TcpListener { /// Create a new TcpListener with the provided raw epoll flags. /// /// These flags replace any epoll flags would normally set when registering the fd. + /// + /// **Note**: This is an [unstable API][unstable]. The public API of this may break in 1.x + /// releases. + /// See [the documentation on unstable features][unstable] for details. + /// + /// [unstable]: crate#unstable-features #[track_caller] #[cfg(all(target_os = "linux", tokio_unstable))] - pub fn from_std_with_flags(listener: net::TcpListener, flags: u32) -> io::Result { + #[cfg_attr(docsrs, doc(cfg(tokio_unstable)), doc(cfg(target_os = "linux")))] + pub fn from_std_with_epoll_flags( + listener: net::TcpListener, + flags: u32, + ) -> io::Result { let io = mio::net::TcpListener::from_std(listener); let io = PollEvented::new_raw(io, flags)?; Ok(TcpListener { io }) diff --git a/tokio/src/net/unix/listener.rs b/tokio/src/net/unix/listener.rs index 9755017e7..a7722ee38 100644 --- a/tokio/src/net/unix/listener.rs +++ b/tokio/src/net/unix/listener.rs @@ -117,9 +117,16 @@ impl UnixListener { /// Create a new UnixListener with the provided raw epoll flags. /// /// These flags replace any epoll flags would normally set when registering the fd. + /// + /// **Note**: This is an [unstable API][unstable]. The public API of this may break in 1.x + /// releases. + /// See [the documentation on unstable features][unstable] for details. + /// + /// [unstable]: crate#unstable-features #[track_caller] #[cfg(all(target_os = "linux", tokio_unstable))] - pub fn from_std_with_flags( + #[cfg_attr(docsrs, doc(cfg(tokio_unstable)), doc(cfg(target_os = "linux")))] + pub fn from_std_with_epoll_flags( listener: net::UnixListener, flags: u32, ) -> io::Result { diff --git a/tokio/tests/epollexclusive.rs b/tokio/tests/epollexclusive.rs index 0ece90895..50f863f23 100644 --- a/tokio/tests/epollexclusive.rs +++ b/tokio/tests/epollexclusive.rs @@ -84,7 +84,7 @@ fn count_accepts(std: std::net::TcpListener, flags: u32, barrier: Arc) rt.block_on(async { std.set_nonblocking(true).unwrap(); - let listener = tokio::net::TcpListener::from_std_with_flags(std, flags).unwrap(); + let listener = tokio::net::TcpListener::from_std_with_epoll_flags(std, flags).unwrap(); barrier.wait().await;