Fix GitHub Actions for threading.

PiperOrigin-RevId: 922926969
Change-Id: I968e6b130b6125dbc0ec65ba913d04292270b563
This commit is contained in:
Kyle Bayes
2026-05-28 12:56:19 -07:00
committed by Copybara-Service
parent 9436972a22
commit b612d352d4
3 changed files with 35 additions and 4 deletions
+24 -1
View File
@@ -24,6 +24,10 @@
#include <mujoco/mjmodel.h>
#include "engine/engine_memory.h"
#if defined(__cpp_lib_atomic_wait)
// ----------------------------- multithreaded implementation --------------------------------------
// context for thread pool stored on mjData
class ThreadPoolContext {
public:
@@ -129,7 +133,6 @@ class ThreadPoolContext {
};
// create a thread pool with nthread threads
void mju_threadpool(mjData* d, int nthread) {
if (d->threadpool) {
@@ -188,3 +191,23 @@ int mju_numThread(const mjData* d) {
ThreadPoolContext* ctx = reinterpret_cast<ThreadPoolContext*>(d->threadpool);
return ctx ? ctx->ThreadCount() + 1 : 1;
}
#else
// -------------------------------------- fallback ------------------------------------------------
void mju_threadpool(mjData* d, int nthread) {
// No-op
}
void mju_dispatch(const mjModel* m, mjData* d, mjTaskFunc func, void* arg, int ntask) {
for (int i = 0; i < ntask; i++) {
func(m, d, arg, 0, i);
}
}
int mju_numThread(const mjData* d) {
return 1;
}
#endif // __cpp_lib_atomic_wait