Skip to content

Commit

Permalink
Refs 12758. Different removal policy on ReaderHistory and DataReaderH…
Browse files Browse the repository at this point in the history
…istory.

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
  • Loading branch information
MiguelCompany committed Dec 16, 2021
1 parent 02be117 commit 353ac53
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 9 deletions.
10 changes: 1 addition & 9 deletions include/fastdds/rtps/history/ReaderHistory.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,7 @@ class ReaderHistory : public History
*/
RTPS_DllAPI virtual void writer_unmatched(
const GUID_t& writer_guid,
const SequenceNumber_t& last_notified_seq)
{
remove_changes_with_pred(
[writer_guid, last_notified_seq](CacheChange_t* ch)
{
return (writer_guid == ch->writerGUID) &&
(last_notified_seq < ch->sequenceNumber);
});
}
const SequenceNumber_t& last_notified_seq);

protected:

Expand Down
11 changes: 11 additions & 0 deletions src/cpp/fastdds/subscriber/history/DataReaderHistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,17 @@ bool DataReaderHistory::find_key(
return false;
}

void DataReaderHistory::writer_unmatched(
const GUID_t& writer_guid,
const SequenceNumber_t& last_notified_seq)
{
remove_changes_with_pred(
[&writer_guid, &last_notified_seq](CacheChange_t* ch)
{
return (writer_guid == ch->writerGUID) && (last_notified_seq < ch->sequenceNumber);
});
}

bool DataReaderHistory::remove_change_sub(
CacheChange_t* change)
{
Expand Down
15 changes: 15 additions & 0 deletions src/cpp/fastdds/subscriber/history/DataReaderHistory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include <fastdds/rtps/common/CacheChange.h>
#include <fastdds/rtps/common/Guid.h>
#include <fastdds/rtps/common/InstanceHandle.h>
#include <fastdds/rtps/common/SequenceNumber.h>
#include <fastdds/rtps/history/ReaderHistory.h>
#include <fastdds/rtps/resources/ResourceManagement.h>

Expand All @@ -60,6 +61,7 @@ class DataReaderHistory : public eprosima::fastrtps::rtps::ReaderHistory
using InstanceHandle_t = eprosima::fastrtps::rtps::InstanceHandle_t;
using CacheChange_t = eprosima::fastrtps::rtps::CacheChange_t;
using GUID_t = eprosima::fastrtps::rtps::GUID_t;
using SequenceNumber_t = eprosima::fastrtps::rtps::SequenceNumber_t;

using instance_info = std::pair<InstanceHandle_t, DataReaderInstance*>;

Expand Down Expand Up @@ -153,6 +155,19 @@ class DataReaderHistory : public eprosima::fastrtps::rtps::ReaderHistory
CacheChange_t* change,
DataReaderInstance::ChangeCollection::iterator& it);

/**
* Called when a writer is unmatched from the reader holding this history.
*
* This method will remove all the changes on the history that came from the writer being unmatched and which have
* not yet been notified to the user.
*
* @param writer_guid GUID of the writer being unmatched.
* @param last_notified_seq Last sequence number from the specified writer that was notified to the user.
*/
void writer_unmatched(
const GUID_t& writer_guid,
const SequenceNumber_t& last_notified_seq) override;

/**
* @brief A method to set the next deadline for the given instance
* @param handle The handle to the instance
Expand Down
12 changes: 12 additions & 0 deletions src/cpp/rtps/history/ReaderHistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,18 @@ History::iterator ReaderHistory::remove_change_nts(
return ret_val;
}

void ReaderHistory::writer_unmatched(
const GUID_t& writer_guid,
const SequenceNumber_t& last_notified_seq)
{
static_cast<void>(last_notified_seq);
remove_changes_with_pred(
[&writer_guid](CacheChange_t* ch)
{
return writer_guid == ch->writerGUID;
});
}

bool ReaderHistory::remove_changes_with_guid(
const GUID_t& a_guid)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ class ReaderHistory

protected:

template<typename Pred>
inline void remove_changes_with_pred(
Pred pred)
{
}

RTPSReader* mp_reader;
RecursiveTimedMutex* mp_mutex;
std::vector<CacheChange_t*> m_changes;
Expand Down

0 comments on commit 353ac53

Please sign in to comment.