]>
git.proxmox.com Git - rustc.git/blob - vendor/num_threads/src/linux.rs
2 use std
::num
::NonZeroUsize
;
4 pub(crate) fn num_threads() -> Option
<NonZeroUsize
> {
5 fs
::read_to_string("/proc/self/stat")
8 // Skip past the pid and (process name) fields
9 .and_then(|stat
| stat
.rsplit('
)'
).next())
10 // 20th field, less the two we skipped
11 .and_then(|rstat
| rstat
.split_whitespace().nth(17))
12 .and_then(|num_threads
| num_threads
.parse
::<usize>().ok())
13 .and_then(NonZeroUsize
::new
)