Expand description
Fast and flexible thread identifiers.
The main reason this crate exists is performance.
Retrieving any of these ids is 30x faster than calling
std::thread::current,
which calls Arc::clone internally.
The three types of ids StdThreadId, UniqueThreadId, and LiveThreadId
are roughly equivalent in lookup performance
The other reason this crate exists is flexibility.
Using LiveThreadId will aggressively reuse thread ids to minimize the integer value of ids,
making it useful as a key in a vector of live threads.
Using debug::DebugThreadId is a convenience wrapper which displays std::thread::Thread::name
where possible, in addition to using UniqueThreadId as a fallback when the thread is unnamed.
§Similar Crates
The crate name and functionality is similar to that of the thread-id crate,
which simply wraps OS primitives (pthreads/windows).
Make sure you are using the right crate.
They have very different APIs.
Re-exports§
pub use live::LiveThreadId;stdpub use unique::UniqueThreadId;pub use self::std::StdThreadId;std
Modules§
- debug
std - Identifies a thread in a form useful for debugging.
- live
std - Defines a
LiveThreadId. - std
std - Wraps
std::thread::ThreadId, providng faster lookup. - unique
- Defines
UniqueThreadId.
Traits§
- IThread
Id - Defines methods common to all thread ids.
Functions§
- current
- Get the id of the current thread.