Fix GCC and MSVC build.
PiperOrigin-RevId: 564390190 Change-Id: Icba3eefb394b8d17798679dd9876f127fba5a599
This commit is contained in:
committed by
Copybara-Service
parent
78183e60e1
commit
860f7b376a
@@ -99,12 +99,9 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang
|
|||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
# Set -Wimplicit-fallthrough=5 to only allow fallthrough annotation via __attribute__.
|
# Set -Wimplicit-fallthrough=5 to only allow fallthrough annotation via __attribute__.
|
||||||
set(EXTRA_COMPILE_OPTIONS ${EXTRA_COMPILE_OPTIONS} -Wimplicit-fallthrough=5
|
set(EXTRA_COMPILE_OPTIONS ${EXTRA_COMPILE_OPTIONS} -Wimplicit-fallthrough=5
|
||||||
-Wno-maybe-uninitialized -Wno-c++20-extensions
|
-Wno-maybe-uninitialized
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
||||||
set(EXTRA_COMPILE_OPTIONS ${EXTRA_COMPILE_OPTIONS} -Wno-c++20-designator)
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(MujocoHarden)
|
include(MujocoHarden)
|
||||||
|
|||||||
@@ -99,12 +99,9 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang
|
|||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
# Set -Wimplicit-fallthrough=5 to only allow fallthrough annotation via __attribute__.
|
# Set -Wimplicit-fallthrough=5 to only allow fallthrough annotation via __attribute__.
|
||||||
set(EXTRA_COMPILE_OPTIONS ${EXTRA_COMPILE_OPTIONS} -Wimplicit-fallthrough=5
|
set(EXTRA_COMPILE_OPTIONS ${EXTRA_COMPILE_OPTIONS} -Wimplicit-fallthrough=5
|
||||||
-Wno-maybe-uninitialized -Wno-c++20-extensions
|
-Wno-maybe-uninitialized
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
||||||
set(EXTRA_COMPILE_OPTIONS ${EXTRA_COMPILE_OPTIONS} -Wno-c++20-designator)
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(MujocoHarden)
|
include(MujocoHarden)
|
||||||
|
|||||||
@@ -99,12 +99,9 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang
|
|||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||||
# Set -Wimplicit-fallthrough=5 to only allow fallthrough annotation via __attribute__.
|
# Set -Wimplicit-fallthrough=5 to only allow fallthrough annotation via __attribute__.
|
||||||
set(EXTRA_COMPILE_OPTIONS ${EXTRA_COMPILE_OPTIONS} -Wimplicit-fallthrough=5
|
set(EXTRA_COMPILE_OPTIONS ${EXTRA_COMPILE_OPTIONS} -Wimplicit-fallthrough=5
|
||||||
-Wno-maybe-uninitialized -Wno-c++20-extensions
|
-Wno-maybe-uninitialized
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
||||||
set(EXTRA_COMPILE_OPTIONS ${EXTRA_COMPILE_OPTIONS} -Wno-c++20-designator)
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(MujocoHarden)
|
include(MujocoHarden)
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <mujoco/mjthread.h>
|
#include <mujoco/mjthread.h>
|
||||||
@@ -41,8 +42,9 @@ struct WorkerThread {
|
|||||||
|
|
||||||
// An mjTask for shutting down this worker.
|
// An mjTask for shutting down this worker.
|
||||||
mjTask shutdown_task_ {
|
mjTask shutdown_task_ {
|
||||||
.func = &ShutdownFunction,
|
&ShutdownFunction,
|
||||||
.args = nullptr,
|
nullptr,
|
||||||
|
mjTASK_NEW
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
} // namespace
|
} // namespace
|
||||||
@@ -51,11 +53,12 @@ struct WorkerThread {
|
|||||||
// (The public mjThreadPool C struct is an opaque one.)
|
// (The public mjThreadPool C struct is an opaque one.)
|
||||||
class ThreadPoolImpl : public mjThreadPool {
|
class ThreadPoolImpl : public mjThreadPool {
|
||||||
public:
|
public:
|
||||||
ThreadPoolImpl(int num_worker) : mjThreadPool{.nworker = num_worker} {
|
ThreadPoolImpl(int num_worker) : mjThreadPool{num_worker} {
|
||||||
// initialize worker threads
|
// initialize worker threads
|
||||||
for (int i = 0; i < num_worker; ++i) {
|
for (int i = 0; i < num_worker; ++i) {
|
||||||
workers_.push_back(
|
WorkerThread worker{
|
||||||
{std::make_unique<std::thread>(ThreadPoolWorker, this)});
|
std::make_unique<std::thread>(ThreadPoolWorker, this)};
|
||||||
|
workers_.push_back(std::move(worker));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user