pub struct Id(/* private fields */);
Available on
tokio_unstable
and crate feature rt
only.Expand description
An opaque ID that uniquely identifies a runtime relative to all other currently running runtimes.
§Notes
- Runtime IDs are unique relative to other currently running runtimes. When a runtime completes, the same ID may be used for another runtime.
- Runtime IDs are not sequential, and do not indicate the order in which runtimes are started or any other data.
- The runtime ID of the currently running task can be obtained from the Handle.
§Examples
use tokio::runtime::Handle;
#[tokio::main(flavor = "multi_thread", worker_threads = 4)]
async fn main() {
println!("Current runtime id: {}", Handle::current().id());
}
Note: This is an unstable API. The public API of this type may break in 1.x releases. See the documentation on unstable features for details.
Trait Implementations§
Source§impl From<NonZero<u32>> for Id
impl From<NonZero<u32>> for Id
Source§fn from(value: NonZeroU32) -> Self
fn from(value: NonZeroU32) -> Self
Converts to this type from the input type.
Source§impl From<NonZero<u64>> for Id
impl From<NonZero<u64>> for Id
Source§fn from(value: NonZeroU64) -> Self
fn from(value: NonZeroU64) -> Self
Converts to this type from the input type.
impl Copy for Id
impl Eq 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 UnwindSafe for Id
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more