mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
runtime: use GetCurrentProcessorNumber for runtime.nr_cpus()
This commit is contained in:
parent
acbfc11eef
commit
b999d01de7
@ -2,8 +2,16 @@ module runtime
|
||||
|
||||
import os
|
||||
|
||||
[typedef]
|
||||
struct C.SYSTEM_INFO {
|
||||
dwNumberOfProcessors u32
|
||||
}
|
||||
fn C.GetSystemInfo(&C.SYSTEM_INFO)
|
||||
|
||||
pub fn nr_cpus() int {
|
||||
mut nr := int(C.GetCurrentProcessorNumber())
|
||||
sinfo := C.SYSTEM_INFO{}
|
||||
C.GetSystemInfo(&sinfo)
|
||||
mut nr := int(sinfo.dwNumberOfProcessors)
|
||||
if nr == 0 {
|
||||
nr = os.getenv('NUMBER_OF_PROCESSORS').int()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user