common: limit max number of threads to hardware limit

This commit is contained in:
Tyler Wilding
2026-07-14 20:34:14 -04:00
parent 4e19f9435e
commit 1edbf4059e
+3 -1
View File
@@ -10,6 +10,8 @@ void SimpleThreadGroup::run(const std::function<void(int)>& func, int num_runs)
void SimpleThreadGroup::run(const std::function<void(int)>& 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;
}
}