2019-11-15 14:14:28 +01:00
|
|
|
module runtime
|
|
|
|
|
2020-07-20 16:36:44 +02:00
|
|
|
pub fn nr_cpus() int {
|
2019-11-15 14:14:28 +01:00
|
|
|
$if linux {
|
|
|
|
return int(C.sysconf(C._SC_NPROCESSORS_ONLN))
|
|
|
|
}
|
2020-01-09 11:12:35 +01:00
|
|
|
$if macos {
|
2019-11-15 14:14:28 +01:00
|
|
|
return int(C.sysconf(C._SC_NPROCESSORS_ONLN))
|
|
|
|
}
|
2020-03-21 09:48:02 +01:00
|
|
|
$if solaris {
|
|
|
|
return int(C.sysconf(C._SC_NPROCESSORS_ONLN))
|
|
|
|
}
|
2019-11-15 14:14:28 +01:00
|
|
|
return 1
|
2020-07-20 16:36:44 +02:00
|
|
|
}
|