2019-11-15 16:14:28 +03:00
|
|
|
module runtime
|
|
|
|
|
2020-12-27 21:14:43 +03:00
|
|
|
// nr_cpus returns the number of virtual CPU cores found on the system.
|
2020-07-20 17:36:44 +03:00
|
|
|
pub fn nr_cpus() int {
|
2019-11-15 16:14:28 +03:00
|
|
|
$if linux {
|
|
|
|
return int(C.sysconf(C._SC_NPROCESSORS_ONLN))
|
|
|
|
}
|
2020-01-09 13:12:35 +03:00
|
|
|
$if macos {
|
2019-11-15 16:14:28 +03:00
|
|
|
return int(C.sysconf(C._SC_NPROCESSORS_ONLN))
|
|
|
|
}
|
2020-03-21 11:48:02 +03:00
|
|
|
$if solaris {
|
|
|
|
return int(C.sysconf(C._SC_NPROCESSORS_ONLN))
|
|
|
|
}
|
2019-11-15 16:14:28 +03:00
|
|
|
return 1
|
2020-12-27 21:14:43 +03:00
|
|
|
}
|