Skip to content

Commit

Permalink
Refs #19435. SystemInfo::watch_file receives thread settings.
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
  • Loading branch information
MiguelCompany committed Oct 11, 2023
1 parent 59b53c0 commit 41c3702
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/cpp/rtps/RTPSDomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down
8 changes: 6 additions & 2 deletions src/cpp/utils/SystemInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,9 @@ const std::string& SystemInfo::get_environment_file()

FileWatchHandle SystemInfo::watch_file(
std::string filename,
std::function<void()> callback)
std::function<void()> 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<std::string>(filename,
Expand All @@ -229,10 +231,12 @@ FileWatchHandle SystemInfo::watch_file(
// No-op
break;
}
}, {}, {}));
}, watch_thread_config, callback_thread_config));
#else // defined(_WIN32) || defined(__unix__)
static_cast<void>(filename);
static_cast<void>(callback);
static_cast<void>(watch_thread_config);
static_cast<void>(callback_thread_config);
return FileWatchHandle();
#endif // defined(_WIN32) || defined(__unix__)
}
Expand Down
8 changes: 7 additions & 1 deletion src/cpp/utils/SystemInfo.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include <memory>
#include <string>

#include <fastdds/rtps/attributes/ThreadSettings.hpp>

#include <fastrtps/types/TypesBase.h>
#include <utils/Host.hpp>

Expand Down Expand Up @@ -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<void()> callback);
std::function<void()> callback,
const fastdds::rtps::ThreadSettings& watch_thread_config,
const fastdds::rtps::ThreadSettings& callback_thread_config);

/**
* Stop a file watcher.
Expand Down
2 changes: 1 addition & 1 deletion test/unittest/utils/SystemInfoTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ TEST_F(SystemInfoTests, FileWatchTest)
eprosima::SystemInfo::wait_for_file_closure(filename, _1s);
++times_called_;
cv_.notify_all();
});
}, {}, {});

// Read contents
{
Expand Down

0 comments on commit 41c3702

Please sign in to comment.