Skip to content

Commit

Permalink
task: stabilize task::Id related apis (#6891)
Browse files Browse the repository at this point in the history
  • Loading branch information
mox692 authored Oct 11, 2024
1 parent 161b8c8 commit 5ada511
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 19 deletions.
1 change: 0 additions & 1 deletion tokio/src/runtime/scheduler/current_thread/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,6 @@ impl Handle {
let (handle, notified) = me.shared.owned.bind(future, me.clone(), id);

me.task_hooks.spawn(&TaskMeta {
#[cfg(tokio_unstable)]
id,
_phantom: Default::default(),
});
Expand Down
1 change: 0 additions & 1 deletion tokio/src/runtime/scheduler/multi_thread/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ impl Handle {
let (handle, notified) = me.shared.owned.bind(future, me.clone(), id);

me.task_hooks.spawn(&TaskMeta {
#[cfg(tokio_unstable)]
id,
_phantom: Default::default(),
});
Expand Down
7 changes: 0 additions & 7 deletions tokio/src/runtime/task/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,7 @@ impl JoinError {
/// Returns a [task ID] that identifies the task which errored relative to
/// other currently spawned tasks.
///
/// **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(tokio_unstable)]
#[cfg_attr(docsrs, doc(cfg(tokio_unstable)))]
pub fn id(&self) -> Id {
self.id
}
Expand Down
1 change: 0 additions & 1 deletion tokio/src/runtime/task/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,6 @@ where
if let Some(f) = self.trailer().hooks.task_terminate_callback.as_ref() {
let _ = panic::catch_unwind(panic::AssertUnwindSafe(|| {
f(&TaskMeta {
#[cfg(tokio_unstable)]
id: self.core().task_id,
_phantom: Default::default(),
})
Expand Down
3 changes: 1 addition & 2 deletions tokio/src/runtime/task_hooks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@ pub(crate) struct TaskHooks {
#[cfg_attr(not(tokio_unstable), allow(unreachable_pub))]
pub struct TaskMeta<'a> {
/// The opaque ID of the task.
#[cfg(tokio_unstable)]
pub(crate) id: super::task::Id,
pub(crate) _phantom: PhantomData<&'a ()>,
}

impl<'a> TaskMeta<'a> {
/// Return the opaque ID of the task.
#[cfg(tokio_unstable)]
#[cfg_attr(not(tokio_unstable), allow(unreachable_pub, dead_code))]
pub fn id(&self) -> super::task::Id {
self.id
}
Expand Down
7 changes: 0 additions & 7 deletions tokio/src/task/join_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use std::task::{Context, Poll};
use std::{fmt, panic};

use crate::runtime::Handle;
#[cfg(tokio_unstable)]
use crate::task::Id;
use crate::task::{unconstrained, AbortHandle, JoinError, JoinHandle, LocalSet};
use crate::util::IdleNotifiedSet;
Expand Down Expand Up @@ -300,8 +299,6 @@ impl<T: 'static> JoinSet<T> {
///
/// [task ID]: crate::task::Id
/// [`JoinError::id`]: fn@crate::task::JoinError::id
#[cfg(tokio_unstable)]
#[cfg_attr(docsrs, doc(cfg(tokio_unstable)))]
pub async fn join_next_with_id(&mut self) -> Option<Result<(Id, T), JoinError>> {
std::future::poll_fn(|cx| self.poll_join_next_with_id(cx)).await
}
Expand Down Expand Up @@ -338,8 +335,6 @@ impl<T: 'static> JoinSet<T> {
///
/// [task ID]: crate::task::Id
/// [`JoinError::id`]: fn@crate::task::JoinError::id
#[cfg(tokio_unstable)]
#[cfg_attr(docsrs, doc(cfg(tokio_unstable)))]
pub fn try_join_next_with_id(&mut self) -> Option<Result<(Id, T), JoinError>> {
// Loop over all notified `JoinHandle`s to find one that's ready, or until none are left.
loop {
Expand Down Expand Up @@ -544,8 +539,6 @@ impl<T: 'static> JoinSet<T> {
///
/// [coop budget]: crate::task#cooperative-scheduling
/// [task ID]: crate::task::Id
#[cfg(tokio_unstable)]
#[cfg_attr(docsrs, doc(cfg(tokio_unstable)))]
pub fn poll_join_next_with_id(
&mut self,
cx: &mut Context<'_>,
Expand Down

0 comments on commit 5ada511

Please sign in to comment.