diff --git a/tokio/src/task/local.rs b/tokio/src/task/local.rs index e80307f3b0a..c1764300bcd 100644 --- a/tokio/src/task/local.rs +++ b/tokio/src/task/local.rs @@ -1,7 +1,6 @@ //! Runs `!Send` futures on the current thread. use crate::loom::cell::UnsafeCell; use crate::loom::sync::{Arc, Mutex}; -#[cfg(tokio_unstable)] use crate::runtime; use crate::runtime::task::{ self, JoinHandle, LocalOwnedTasks, SpawnLocation, Task, TaskHarnessScheduleHooks, @@ -844,6 +843,25 @@ impl LocalSet { Err(_access_error) => (f.take().unwrap())(), } } + + /// Returns the [`Id`] of the current [`LocalSet`] runtime. + /// + /// # Examples + /// + /// ```rust + /// use tokio::task; + /// + /// # #[tokio::main(flavor = "current_thread")] + /// # async fn main() { + /// let local_set = task::LocalSet::new(); + /// println!("Local set id: {}", local_set.id()); + /// # } + /// ``` + /// + /// [`Id`]: struct@crate::runtime::Id + pub fn id(&self) -> runtime::Id { + runtime::Id::new(self.context.shared.local_state.owned.id) + } } cfg_unstable! { @@ -914,30 +932,6 @@ cfg_unstable! { .unhandled_panic = behavior; self } - - /// Returns the [`Id`] of the current `LocalSet` runtime. - /// - /// # Examples - /// - /// ```rust - /// use tokio::task; - /// - /// # #[tokio::main(flavor = "current_thread")] - /// # async fn main() { - /// let local_set = task::LocalSet::new(); - /// println!("Local set id: {}", local_set.id()); - /// # } - /// ``` - /// - /// **Note**: This is an [unstable API][unstable]. The public API of this type - /// may break in 1.x releases. See [the documentation on unstable - /// features][unstable] for details. - /// - /// [unstable]: crate#unstable-features - /// [`Id`]: struct@crate::runtime::Id - pub fn id(&self) -> runtime::Id { - runtime::Id::new(self.context.shared.local_state.owned.id) - } } }