diff --git a/common/util/SimpleThreadGroup.cpp b/common/util/SimpleThreadGroup.cpp index aea1917a4d..a7e4c750c8 100644 --- a/common/util/SimpleThreadGroup.cpp +++ b/common/util/SimpleThreadGroup.cpp @@ -13,6 +13,8 @@ void SimpleThreadGroup::run(const std::function& func, int num_runs, // copy the function, in case the user gives us a temporary function. m_func = func; + num_workers = std::min(num_workers, std::thread::hardware_concurrency()); + int start_idx = 0; for (int thread_idx = 0; thread_idx < num_workers; thread_idx++) { int end_idx = ((thread_idx + 1) * num_runs) / num_workers;