Use std::thread::hardware_concurrency, instead of Boost, to determine available cores

This commit is contained in:
fanquake committed 2017-12-15 14:47:43 +08:00
1 parent c66adb286a
commit 937bf4335b
2 files changed
+4 -8

No files matched your search

+2 -5
View File
@@ -77,6 +77,7 @@
#include <openssl/crypto.h> #include <openssl/crypto.h>
#include <openssl/rand.h> #include <openssl/rand.h>
#include <openssl/conf.h> #include <openssl/conf.h>
#include <thread>
// Application startup time (used for uptime calculation) // Application startup time (used for uptime calculation)
const int64_t nStartupTime = GetTime(); const int64_t nStartupTime = GetTime();
@@ -891,11 +892,7 @@ bool SetupNetworking()
int GetNumCores() int GetNumCores()
{ {
#if BOOST_VERSION >= 105600 return std::thread::hardware_concurrency();
return boost::thread::physical_concurrency();
#else // Must fall back to hardware_concurrency, which unfortunately counts virtual cores
return boost::thread::hardware_concurrency();
#endif
} }
std::string CopyrightHolders(const std::string& strPrefix) std::string CopyrightHolders(const std::string& strPrefix)
+2 -3
View File
@@ -295,9 +295,8 @@ std::string HelpMessageGroup(const std::string& message);
std::string HelpMessageOpt(const std::string& option, const std::string& message); std::string HelpMessageOpt(const std::string& option, const std::string& message);
/** /**
* Return the number of physical cores available on the current system. * Return the number of cores available on the current system.
* @note This does not count virtual cores, such as those provided by HyperThreading * @note This does count virtual cores, such as those provided by HyperThreading.
* when boost is newer than 1.56.
*/ */
int GetNumCores(); int GetNumCores();