#thread #amount #process #numbers #current

thread-amount

Get the amount of threads in the current process

4 releases

0.1.3 Jun 24, 2022
0.1.2 Jun 1, 2022
0.1.1 Jun 1, 2022
0.1.0 Jun 1, 2022

#156 in Windows APIs

MIT license

11KB
96 lines

thread-amount

Crate Version Documentation License Continuous Delivery Continuous Integration

Get the amount of threads in the current process

Example Usage

Cargo.toml

[dependencies]
thread-amount = "0.1"

The code:

use thread_amount::thread_amount;

use std::thread;

fn main() {
    let amount = thread_amount();

    thread::spawn(move || {
        assert_eq!(amount.map(NonZeroUsize::get), Some(1))
    });
}

Difference between num-threads

This crate has windows support and reads the /proc/[PID]/status file in -unix systems.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Tomio

💻 📖 💡 🚇 🚧

This project follows the all-contributors specification. Contributions of any kind welcome!

License

Licensed under the MIT license (LICENSE or http://opensource.org/licenses/MIT)

Dependencies

~0–40MB
~561K SLoC