mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-25 12:00:35 +00:00
task: stabilize task::Id
related apis (#6891)
This commit is contained in:
parent
161b8c80d5
commit
5ada5114df
@ -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(),
|
||||
});
|
||||
|
@ -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(),
|
||||
});
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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(),
|
||||
})
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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;
|
||||
@ -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
|
||||
}
|
||||
@ -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 {
|
||||
@ -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<'_>,
|
||||
|
Loading…
x
Reference in New Issue
Block a user