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:
committed by
Copybara-Service
parent
1704f51df6
commit
86aae0f5a5
@@ -2510,17 +2510,12 @@ void mjCModel::LengthRange(mjModel* m, mjData* data) {
|
|||||||
err[i][0] = 0;
|
err[i][0] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// launch threads
|
// launch threads and wait for them to finish
|
||||||
std::vector<std::thread> th;
|
mujoco::user::ThreadPool pool(nthread);
|
||||||
th.reserve(nthread);
|
|
||||||
for (int i=0; i < nthread; i++) {
|
for (int i=0; i < nthread; i++) {
|
||||||
th.emplace_back(LRfunc, &arg[i]);
|
pool.Schedule([&arg, i]() { LRfunc(&arg[i]); });
|
||||||
}
|
|
||||||
|
|
||||||
// wait for threads to finish
|
|
||||||
for (int i=0; i < nthread; i++) {
|
|
||||||
th[i].join();
|
|
||||||
}
|
}
|
||||||
|
pool.WaitCount(nthread);
|
||||||
|
|
||||||
// free mjData allocated here
|
// free mjData allocated here
|
||||||
for (int i=1; i < nthread; i++) {
|
for (int i=1; i < nthread; i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user