From 41c37026ddf342dc97bf9347ce706c2c3f9ffc93 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Tue, 10 Oct 2023 16:38:57 +0200 Subject: [PATCH] Refs #19435. SystemInfo::watch_file receives thread settings. Signed-off-by: Miguel Company --- src/cpp/rtps/RTPSDomain.cpp | 2 +- src/cpp/utils/SystemInfo.cpp | 8 ++++++-- src/cpp/utils/SystemInfo.hpp | 8 +++++++- test/unittest/utils/SystemInfoTests.cpp | 2 +- 4 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/cpp/rtps/RTPSDomain.cpp b/src/cpp/rtps/RTPSDomain.cpp index d89595b498f..22ea30afe87 100644 --- a/src/cpp/rtps/RTPSDomain.cpp +++ b/src/cpp/rtps/RTPSDomain.cpp @@ -144,7 +144,7 @@ RTPSParticipant* RTPSDomainImpl::createParticipant( if (!filename.empty() && SystemInfo::file_exists(filename)) { // Create filewatch - instance->file_watch_handle_ = SystemInfo::watch_file(filename, RTPSDomainImpl::file_watch_callback); + instance->file_watch_handle_ = SystemInfo::watch_file(filename, RTPSDomainImpl::file_watch_callback, {}, {}); } else if (!filename.empty()) { diff --git a/src/cpp/utils/SystemInfo.cpp b/src/cpp/utils/SystemInfo.cpp index 42f365720df..8c285d39b0e 100644 --- a/src/cpp/utils/SystemInfo.cpp +++ b/src/cpp/utils/SystemInfo.cpp @@ -214,7 +214,9 @@ const std::string& SystemInfo::get_environment_file() FileWatchHandle SystemInfo::watch_file( std::string filename, - std::function callback) + std::function callback, + const fastdds::rtps::ThreadSettings& watch_thread_config, + const fastdds::rtps::ThreadSettings& callback_thread_config) { #if defined(_WIN32) || defined(__unix__) return FileWatchHandle (new filewatch::FileWatch(filename, @@ -229,10 +231,12 @@ FileWatchHandle SystemInfo::watch_file( // No-op break; } - }, {}, {})); + }, watch_thread_config, callback_thread_config)); #else // defined(_WIN32) || defined(__unix__) static_cast(filename); static_cast(callback); + static_cast(watch_thread_config); + static_cast(callback_thread_config); return FileWatchHandle(); #endif // defined(_WIN32) || defined(__unix__) } diff --git a/src/cpp/utils/SystemInfo.hpp b/src/cpp/utils/SystemInfo.hpp index d2b4420c4be..418da3d9963 100644 --- a/src/cpp/utils/SystemInfo.hpp +++ b/src/cpp/utils/SystemInfo.hpp @@ -25,6 +25,8 @@ #include #include +#include + #include #include @@ -193,12 +195,16 @@ class SystemInfo * * @param [in] filename Path/name of the file to watch. * @param [in] callback Callback to execute when the file changes. + * @param [in] watch_thread_config Thread settings for watch thread. + * @param [in] callback_thread_config Thread settings for callback thread. * * @return The handle that represents the watcher object. */ static FileWatchHandle watch_file( std::string filename, - std::function callback); + std::function callback, + const fastdds::rtps::ThreadSettings& watch_thread_config, + const fastdds::rtps::ThreadSettings& callback_thread_config); /** * Stop a file watcher. diff --git a/test/unittest/utils/SystemInfoTests.cpp b/test/unittest/utils/SystemInfoTests.cpp index 58af62ed4e4..075a4ae0c84 100644 --- a/test/unittest/utils/SystemInfoTests.cpp +++ b/test/unittest/utils/SystemInfoTests.cpp @@ -238,7 +238,7 @@ TEST_F(SystemInfoTests, FileWatchTest) eprosima::SystemInfo::wait_for_file_closure(filename, _1s); ++times_called_; cv_.notify_all(); - }); + }, {}, {}); // Read contents {