https://github.com/ruuda/thread-id
Get a unique thread ID in Rust
https://github.com/ruuda/thread-id
Last synced: about 1 year ago
JSON representation
Get a unique thread ID in Rust
- Host: GitHub
- URL: https://github.com/ruuda/thread-id
- Owner: ruuda
- License: other
- Created: 2016-03-12T16:29:30.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2023-12-27T07:36:53.000Z (over 2 years ago)
- Last Synced: 2024-04-24T09:24:44.225Z (about 2 years ago)
- Language: Rust
- Homepage:
- Size: 609 KB
- Stars: 41
- Watchers: 3
- Forks: 21
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- Changelog: changelog.md
- Contributing: contributing.md
- License: license-apache
Awesome Lists containing this project
README
Thread-ID
=========
Get a unique ID for the current thread in Rust.
[![Crates.io version][crate-img]][crate]
[![Documentation][docs-img]][docs]
For diagnostics and debugging it can often be useful to get an ID that is
different for every thread. [Until Rust 1.14][stdlib-pr], the standard library
did not expose a way to do that, hence this crate.
Example
-------
```rust
use std::thread;
use thread_id;
let handle = thread::spawn(move || {
println!("spawned thread has id {}", thread_id::get());
});
println!("main thread has id {}", thread_id::get());
handle.join().unwrap();
```
This will print two different numbers.
License
-------
Thread-ID is licensed under either the [Apache 2.0 license][apache2], or the
[MIT license][mit], at your option. It may be used in free software as well as
closed-source applications, both for commercial and non-commercial use under the
conditions given in the license.
Contributing
------------
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache 2.0 license, shall be
dual licensed as above, without any additional terms or conditions.
[crate-img]: https://img.shields.io/crates/v/thread-id.svg
[crate]: https://crates.io/crates/thread-id
[docs-img]: https://img.shields.io/badge/docs-online-blue.svg
[docs]: https://docs.rs/thread-id
[stdlib-pr]: https://github.com/rust-lang/rust/pull/36341
[apache2]: https://www.apache.org/licenses/LICENSE-2.0
[mit]: https://opensource.org/licenses/MIT