Struct Id
pub struct Id(/* private fields */);
Available on crate feature
rt only.An opaque ID that uniquely identifies a task relative to all other currently running tasks.
A task’s ID may be re-used for another task only once both of the following happen:
- The task itself exits.
- There is no active
JoinHandleassociated with this task.
A JoinHandle is considered active in the following situations:
- You are explicitly holding a
JoinHandle,AbortHandle, ortokio_util::task::AbortOnDropHandle. - The task is being tracked by a
JoinSetortokio_util::task::JoinMap.
Notes
- Task IDs are not sequential, and do not indicate the order in which tasks are spawned, what runtime a task is spawned on, or any other data.
- The task ID of the currently running task can be obtained from inside the task via the
task::try_id()andtask::id()functions and from outside the task via theJoinHandle::id()function.
Trait Implementations
impl Copy for Id
impl Eq for Id
impl Ord for Id
fn max(self, other: Self) -> Selfwhere Self: Sized,
Compares and returns the maximum of two values. Read more
impl PartialOrd for Id
impl StructuralPartialEq for Id
Auto Trait Implementations
impl Freeze for Id
impl RefUnwindSafe for Id
impl Send for Id
impl Sync for Id
impl Unpin for Id
impl UnsafeUnpin for Id
impl UnwindSafe for Id
Blanket Implementations
impl<T> BorrowMut<T> for Twhere T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> CloneToUninit for Twhere T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)
impl<T> Instrument for T
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
impl<T> ToString for T
impl<T> WithSubscriber for T
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
MIT License
Copyright © Tokio Contributors
https://docs.rs/tokio/1.53.1/tokio/task/struct.Id.html