Skip to content

Techcable/threadid.rs

Repository files navigation

threadid.rs

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.

License

Licensed under either the Apache 2.0 License or MIT License at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

Fast and flexible thread identifiers.

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE.txt
MIT
LICENSE-MIT.txt

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published