Use user::ThreadPool for actuator lengthrange calculation in addition to mesh and texture compilation

PiperOrigin-RevId: 883099169
Change-Id: Id6832c2ca0b8f45e2f428615ae54df4b8bb6f434
This commit is contained in:
Matija Kecman
2026-03-13 04:54:17 -07:00
committed by Copybara-Service
parent 1704f51df6
commit 86aae0f5a5
+4 -9
View File
@@ -2510,17 +2510,12 @@ void mjCModel::LengthRange(mjModel* m, mjData* data) {
err[i][0] = 0;
}
// launch threads
std::vector<std::thread> th;
th.reserve(nthread);
// launch threads and wait for them to finish
mujoco::user::ThreadPool pool(nthread);
for (int i=0; i < nthread; i++) {
th.emplace_back(LRfunc, &arg[i]);
}
// wait for threads to finish
for (int i=0; i < nthread; i++) {
th[i].join();
pool.Schedule([&arg, i]() { LRfunc(&arg[i]); });
}
pool.WaitCount(nthread);
// free mjData allocated here
for (int i=1; i < nthread; i++) {