mirror of
https://github.com/open-goal/jak-project
synced 2026-08-05 09:34:51 -04:00
common: limit max number of threads to hardware limit
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user