Skip to content

Commit

Permalink
task: graduate Id to stable API
Browse files Browse the repository at this point in the history
  • Loading branch information
evanrittenhouse committed Aug 18, 2024
1 parent 70569bd commit 32ab357
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 23 deletions.
21 changes: 1 addition & 20 deletions tokio/src/runtime/task/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,7 @@ use std::{fmt, num::NonZeroU64};
/// task via the [`task::try_id()`](crate::task::try_id()) and
/// [`task::id()`](crate::task::id()) functions and from outside the task via
/// the [`JoinHandle::id()`](crate::task::JoinHandle::id()) function.
///
/// **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
#[cfg_attr(docsrs, doc(cfg(all(feature = "rt", tokio_unstable))))]
#[cfg_attr(not(tokio_unstable), allow(unreachable_pub))]
#[cfg_attr(docsrs, doc(cfg(all(feature = "rt"))))]
#[derive(Clone, Copy, Debug, Hash, Eq, PartialEq)]
pub struct Id(pub(crate) NonZeroU64);

Expand All @@ -35,13 +28,7 @@ pub struct Id(pub(crate) NonZeroU64);
/// within a call to `block_on`. For a version of this function that doesn't
/// panic, see [`task::try_id()`](crate::runtime::task::try_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.
///
/// [task ID]: crate::task::Id
/// [unstable]: crate#unstable-features
#[cfg_attr(not(tokio_unstable), allow(unreachable_pub))]
#[track_caller]
pub fn id() -> Id {
context::current_task_id().expect("Can't get a task id when not inside a task")
Expand All @@ -54,13 +41,7 @@ pub fn id() -> Id {
/// that it returns `None` rather than panicking if called outside of a task
/// context.
///
/// **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.
///
/// [task ID]: crate::task::Id
/// [unstable]: crate#unstable-features
#[cfg_attr(not(tokio_unstable), allow(unreachable_pub))]
#[track_caller]
pub fn try_id() -> Option<Id> {
context::current_task_id()
Expand Down
4 changes: 1 addition & 3 deletions tokio/src/task/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,7 @@ cfg_rt! {
#[cfg(tokio_unstable)]
pub mod join_set;

cfg_unstable! {
pub use crate::runtime::task::{Id, id, try_id};
}
pub use crate::runtime::task::{Id, id, try_id};

cfg_trace! {
mod builder;
Expand Down

0 comments on commit 32ab357

Please sign in to comment.