3
Make `std::thread::available_concurrency` support process-limited number of CPUs...
source link: https://github.com/rust-lang/rust/pull/89310
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Use libc::sched_getaffinity
and count the number of CPUs in the returned mask. This handles cases where the process doesn't have access to all CPUs, such as when limited via taskset
or similar.
This also covers cgroup cpusets.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK