Refactor thread pool implementation.
- Make mjTask non-opaque and remove C++ Task class. - Make C++ thread pool a subclass of a skeletal mjThreadPool C struct. - Make the mjTask status enum more consistent with the rest of MuJoCo. - Change mju_threadPoolEnqueue to take just the mjTask. Users must now prepare the mjTask by assigning the function pointer and argument into the struct. - Rename files in thread/ to be more consistent with the rest of MuJoCo. - Run threading tests in CMake. - Allow use of C++20 designated initializers. Otherwise the functionality remains identical. PiperOrigin-RevId: 564374675 Change-Id: I37c9894566bc39faf217e5aa97a4e2713a70e467
This commit is contained in:
committed by
Copybara-Service
parent
0ba10cc4f0
commit
78183e60e1
@@ -403,6 +403,11 @@ public enum mjtFont : int{
|
||||
mjFONT_SHADOW = 1,
|
||||
mjFONT_BIG = 2,
|
||||
}
|
||||
public enum mjtTaskStatus : int{
|
||||
mjTASK_NEW = 0,
|
||||
mjTASK_QUEUED = 1,
|
||||
mjTASK_COMPLETED = 2,
|
||||
}
|
||||
public enum mjtButton : int{
|
||||
mjBUTTON_NONE = 0,
|
||||
mjBUTTON_LEFT = 1,
|
||||
@@ -2360,16 +2365,6 @@ public unsafe struct mjrContext_ {
|
||||
public int readPixelFormat;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public unsafe struct mjTask_ {
|
||||
public fixed sbyte buffer[24];
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public unsafe struct mjThreadPool_ {
|
||||
public fixed sbyte buffer[6208];
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public unsafe struct mjuiState_ {
|
||||
public int nrect;
|
||||
@@ -3950,14 +3945,5 @@ public static unsafe extern void mjd_subQuat(double* qa, double* qb, double* Da,
|
||||
|
||||
[DllImport("mujoco", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static unsafe extern void mjd_quatIntegrate(double* vel, double scale, double* Dquat, double* Dvel, double* Dscale);
|
||||
|
||||
[DllImport("mujoco", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static unsafe extern mjThreadPool_* mju_threadPoolCreate(UIntPtr number_of_threads);
|
||||
|
||||
[DllImport("mujoco", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static unsafe extern void mju_taskJoin(mjTask_* task);
|
||||
|
||||
[DllImport("mujoco", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static unsafe extern void mju_threadPoolDestroy(mjThreadPool_* thread_pool);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user