Gracefully cast from std:🧵:hardware_concurrency

This commit is contained in:
Howard Hinnant
2014-10-14 10:33:10 -04:00
committed by Tom Ritchford
parent 2264ae9247
commit 8caae219cf
2 changed files with 4 additions and 13 deletions

View File

@@ -56,7 +56,8 @@ public:
*/
explicit Workers (Callback& callback,
String const& threadNames = "Worker",
int numberOfThreads = std::thread::hardware_concurrency());
int numberOfThreads =
static_cast<int>(std::thread::hardware_concurrency()));
~Workers ();

View File

@@ -226,18 +226,8 @@ public:
}
else if (c == 0)
{
c = std::thread::hardware_concurrency();
// VFALCO NOTE According to boost, hardware_concurrency cannot return
// negative numbers/
//
if (c < 0)
c = 2; // VFALCO NOTE Why 2?
if (c > 4) // I/O will bottleneck
c = 4;
c += 2;
c = static_cast<int>(std::thread::hardware_concurrency());
c = 2 + std::min (c, 4); // I/O will bottleneck
m_journal.info << "Auto-tuning to " << c <<
" validation/transaction/proposal threads";