diff --git a/common/util/SimpleThreadGroup.cpp b/common/util/SimpleThreadGroup.cpp index aea1917a4d..bdb8c95bec 100644 --- a/common/util/SimpleThreadGroup.cpp +++ b/common/util/SimpleThreadGroup.cpp @@ -10,6 +10,8 @@ void SimpleThreadGroup::run(const std::function& func, int num_runs) void SimpleThreadGroup::run(const std::function& func, int num_runs, int num_workers) { ASSERT(m_joined); + num_workers = std::min(num_workers, (int)std::thread::hardware_concurrency()); + // copy the function, in case the user gives us a temporary function. m_func = func; @@ -39,4 +41,4 @@ void SimpleThreadGroup::join() { } m_threads.clear(); m_joined = true; -} \ No newline at end of file +}