From 47d2901006dd02d019b415404362b49ab1616f07 Mon Sep 17 00:00:00 2001 From: Gilmar Correia Date: Wed, 21 Aug 2024 12:11:26 -0300 Subject: [PATCH 1/2] Update thread_priority.cpp Adding implementation for build on windows. --- src/thread_priority.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/thread_priority.cpp b/src/thread_priority.cpp index 72749e38..3da89524 100644 --- a/src/thread_priority.cpp +++ b/src/thread_priority.cpp @@ -28,7 +28,11 @@ #include "realtime_tools/thread_priority.hpp" -#include +#ifdef _WIN32 + #include +#else + #include +#endif #include #include @@ -47,10 +51,15 @@ bool has_realtime_kernel() bool configure_sched_fifo(int priority) { + #ifdef _WIN32 + HANDLE thread = GetCurrentThread(); + return SetThreadPriority(thread, priority); + #else struct sched_param schedp; memset(&schedp, 0, sizeof(schedp)); schedp.sched_priority = priority; return !sched_setscheduler(0, SCHED_FIFO, &schedp); + #endif } } // namespace realtime_tools From 5e0cdfced92aec3dad1551b7d7139a7eccfa3792 Mon Sep 17 00:00:00 2001 From: GilmarCorreia Date: Wed, 21 Aug 2024 14:57:16 -0300 Subject: [PATCH 2/2] applying clang-format --- src/thread_priority.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/thread_priority.cpp b/src/thread_priority.cpp index 3da89524..58165889 100644 --- a/src/thread_priority.cpp +++ b/src/thread_priority.cpp @@ -29,9 +29,9 @@ #include "realtime_tools/thread_priority.hpp" #ifdef _WIN32 - #include +#include #else - #include +#include #endif #include @@ -51,15 +51,15 @@ bool has_realtime_kernel() bool configure_sched_fifo(int priority) { - #ifdef _WIN32 +#ifdef _WIN32 HANDLE thread = GetCurrentThread(); return SetThreadPriority(thread, priority); - #else +#else struct sched_param schedp; memset(&schedp, 0, sizeof(schedp)); schedp.sched_priority = priority; return !sched_setscheduler(0, SCHED_FIFO, &schedp); - #endif +#endif } } // namespace realtime_tools