From e2137cbe1c24dc451b5301ce4ccf3a50e09f1430 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mario=20Dom=C3=ADnguez=20L=C3=B3pez?= <116071334+Mario-DL@users.noreply.github.com> Date: Mon, 9 Oct 2023 20:11:03 +0100 Subject: [PATCH] Use STL implementation of Timed/RecursiveTimedMutex when MSVC >= 19.36 (#3904) * Refs #19642: Use STL implementation of Timed/RecursiveTimedMutex in MSVC >= 19.36 Signed-off-by: Mario Dominguez * Refs #19642: Linter Signed-off-by: Mario Dominguez --------- Signed-off-by: Mario Dominguez --- include/fastrtps/utils/TimedMutex.hpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/include/fastrtps/utils/TimedMutex.hpp b/include/fastrtps/utils/TimedMutex.hpp index e4ff36a7368..d20fae9cb4a 100644 --- a/include/fastrtps/utils/TimedMutex.hpp +++ b/include/fastrtps/utils/TimedMutex.hpp @@ -23,10 +23,16 @@ #include #if defined(_WIN32) + +#if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 193632528 +#include +#else #include extern int clock_gettime( int, struct timespec* tv); +#endif // if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 193632528 + #elif _GTHREAD_USE_MUTEX_TIMEDLOCK #include #else @@ -38,14 +44,12 @@ namespace fastrtps { #if defined(_WIN32) +#if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 193632528 +using TimedMutex = std::timed_mutex; +using RecursiveTimedMutex = std::recursive_timed_mutex; +#else class TimedMutex { - // On MSVC 19.36.32528.95 `xtime` was changed into `_timespec64`. - // See https://github.com/eProsima/Fast-DDS/issues/3451 - // See https://github.com/microsoft/STL/pull/3594 -#if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 193632528 - using xtime = _timespec64; -#endif // _MSC_FULL_VER check public: @@ -190,6 +194,8 @@ class RecursiveTimedMutex _Mtx_t mutex_; }; +#endif // if defined(_MSC_FULL_VER) && _MSC_FULL_VER >= 193632528 + #elif _GTHREAD_USE_MUTEX_TIMEDLOCK || !defined(__unix__) using TimedMutex = std::timed_mutex; using RecursiveTimedMutex = std::recursive_timed_mutex;