From 64772d4313ea281df9007dbac59d63921b1b2d57 Mon Sep 17 00:00:00 2001 From: Tom Lally Date: Fri, 2 Sep 2022 10:29:13 +0100 Subject: [PATCH] Use std::thread::hardware_concurrency for all platforms. --- src/util/SystemInfo/SystemInfo.cpp | 5 +++++ src/util/SystemInfo/SystemInfoUnix.cpp | 5 ----- src/util/SystemInfo/SystemInfoWin.cpp | 7 ------- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/util/SystemInfo/SystemInfo.cpp b/src/util/SystemInfo/SystemInfo.cpp index fa7d8ecd..afda4e8b 100644 --- a/src/util/SystemInfo/SystemInfo.cpp +++ b/src/util/SystemInfo/SystemInfo.cpp @@ -18,6 +18,11 @@ double ProcessorTime::Compare(ProcessorTime &last, ProcessorTime &now) return (double)dwork / dtotal; } +uint32 GetProcessorCount() +{ + return std::thread::hardware_concurrency(); +} + void QueryProcTime(ProcessorTime &out) { uint64 now, user, kernel; diff --git a/src/util/SystemInfo/SystemInfoUnix.cpp b/src/util/SystemInfo/SystemInfoUnix.cpp index 3127e6a7..9e0d4fb0 100644 --- a/src/util/SystemInfo/SystemInfoUnix.cpp +++ b/src/util/SystemInfo/SystemInfoUnix.cpp @@ -7,11 +7,6 @@ #include -uint32 GetProcessorCount() -{ - return std::thread::hardware_concurrency(); -} - uint64 QueryRamUsage() { long page_size = sysconf(_SC_PAGESIZE); diff --git a/src/util/SystemInfo/SystemInfoWin.cpp b/src/util/SystemInfo/SystemInfoWin.cpp index f955d4af..a9e70045 100644 --- a/src/util/SystemInfo/SystemInfoWin.cpp +++ b/src/util/SystemInfo/SystemInfoWin.cpp @@ -6,13 +6,6 @@ #include #pragma comment(lib, "ntdll.lib") -uint32 GetProcessorCount() -{ - SYSTEM_INFO sys_info; - GetSystemInfo(&sys_info); - return sys_info.dwNumberOfProcessors; -} - uint64 QueryRamUsage() { PROCESS_MEMORY_COUNTERS pmc{};