Skip to content

Commit

Permalink
Refs #19254. Apply suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: Ricardo González Moreno <[email protected]>
  • Loading branch information
richiware committed Sep 11, 2023
1 parent 280d1a7 commit 5c16b98
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/cpp/fastdds/publisher/DataWriterHistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,6 @@ bool DataWriterHistory::remove_change_pub(
return false;
}
#else
static_cast<void>(max_blocking_time);
std::lock_guard<RecursiveTimedMutex> guard(*this->mp_mutex);
#endif // if HAVE_STRICT_REALTIME

Expand Down
9 changes: 9 additions & 0 deletions src/cpp/rtps/history/History.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,16 @@ bool History::remove_change(
CacheChange_t* ch,
const std::chrono::time_point<std::chrono::steady_clock>& max_blocking_time)
{
#if HAVE_STRICT_REALTIME
std::unique_lock<RecursiveTimedMutex> lock(*mp_mutex, std::defer_lock);
if (!lock.try_lock_until(max_blocking_time))
{
EPROSIMA_LOG_ERROR(PUBLISHER, "Cannot lock the DataWriterHistory mutex");
return false;
}
#else
std::lock_guard<RecursiveTimedMutex> guard(*mp_mutex);
#endif // if HAVE_STRICT_REALTIME

const_iterator it = find_change_nts(ch);
const_iterator end_it = changesEnd();
Expand Down
10 changes: 10 additions & 0 deletions src/cpp/rtps/history/WriterHistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,17 @@ bool WriterHistory::remove_min_change(
return false;
}

#if HAVE_STRICT_REALTIME
std::unique_lock<RecursiveTimedMutex> lock(*mp_mutex, std::defer_lock);
if (!lock.try_lock_until(max_blocking_time))
{
EPROSIMA_LOG_ERROR(PUBLISHER, "Cannot lock the DataWriterHistory mutex");
return false;
}
#else
std::lock_guard<RecursiveTimedMutex> guard(*mp_mutex);
#endif // if HAVE_STRICT_REALTIME

if (m_changes.size() > 0 && remove_change_g(m_changes.front(), max_blocking_time))
{
return true;
Expand Down

0 comments on commit 5c16b98

Please sign in to comment.