I want to spawn a certain number of tasks based on the cores that a machine has. Is there anything in Rust that can find the number of cores, or should I just run external commands and parse the output?
There's a crate to do this: num_cpus.
References:
Add this to your Cargo.toml
:
[dependencies]
num_cpus = "1.0"
Then in your source:
extern crate num_cpus;
let num = num_cpus::get();