From ba38d6c55dc364138f10a860c5dc4d67307a3e4f Mon Sep 17 00:00:00 2001 From: Kornel Date: Sun, 14 Feb 2021 14:35:50 +0000 Subject: [PATCH] Doc aliases for pre-1.0 function names --- tokio/src/io/async_fd.rs | 2 ++ tokio/src/runtime/builder.rs | 6 ++++++ tokio/src/sync/notify.rs | 2 ++ tokio/src/time/driver/sleep.rs | 4 ++++ 4 files changed, 14 insertions(+) diff --git a/tokio/src/io/async_fd.rs b/tokio/src/io/async_fd.rs index 13f4f2d62e9..03c24fb14b3 100644 --- a/tokio/src/io/async_fd.rs +++ b/tokio/src/io/async_fd.rs @@ -519,6 +519,8 @@ impl<'a, Inner: AsRawFd> AsyncFdReadyGuard<'a, Inner> { /// create this `AsyncFdReadyGuard`. /// /// [`WouldBlock`]: std::io::ErrorKind::WouldBlock + // Alias for old name in 0.x + #[cfg_attr(docsrs, doc(alias = "with_io"))] pub fn try_io( &mut self, f: impl FnOnce(&AsyncFd) -> io::Result, diff --git a/tokio/src/runtime/builder.rs b/tokio/src/runtime/builder.rs index 33b63e1fe66..ce419388e13 100644 --- a/tokio/src/runtime/builder.rs +++ b/tokio/src/runtime/builder.rs @@ -233,6 +233,12 @@ impl Builder { /// # Panic /// /// This will panic if `val` is not larger than `0`. + /// + /// # Upgrading from 0.x + /// + /// In old versions `max_threads` limited both blocking and worker threads, but the + /// current `max_blocking_threads` does not include async worker threads in the count. + #[cfg_attr(docsrs, doc(alias = "max_threads"))] pub fn max_blocking_threads(&mut self, val: usize) -> &mut Self { assert!(val > 0, "Max blocking threads cannot be set to 0"); self.max_blocking_threads = val; diff --git a/tokio/src/sync/notify.rs b/tokio/src/sync/notify.rs index f39f92f8374..3c34cd0bb68 100644 --- a/tokio/src/sync/notify.rs +++ b/tokio/src/sync/notify.rs @@ -312,6 +312,8 @@ impl Notify { /// notify.notify_one(); /// } /// ``` + // Alias for old name in 0.x + #[cfg_attr(docsrs, doc(alias = "notify"))] pub fn notify_one(&self) { // Load the current state let mut curr = self.state.load(SeqCst); diff --git a/tokio/src/time/driver/sleep.rs b/tokio/src/time/driver/sleep.rs index ef1c7212774..d8173c2524b 100644 --- a/tokio/src/time/driver/sleep.rs +++ b/tokio/src/time/driver/sleep.rs @@ -16,6 +16,8 @@ use std::task::{self, Poll}; /// /// Canceling a sleep instance is done by dropping the returned future. No additional /// cleanup work is required. +// Alias for old name in 0.x +#[cfg_attr(docsrs, doc(alias = "delay_until"))] pub fn sleep_until(deadline: Instant) -> Sleep { Sleep::new_timeout(deadline) } @@ -53,6 +55,8 @@ pub fn sleep_until(deadline: Instant) -> Sleep { /// ``` /// /// [`interval`]: crate::time::interval() +// Alias for old name in 0.x +#[cfg_attr(docsrs, doc(alias = "delay_for"))] pub fn sleep(duration: Duration) -> Sleep { sleep_until(Instant::now() + duration) }