Skip to content

Commit

Permalink
StatelessWriter: implement clean_history()
Browse files Browse the repository at this point in the history
`PublisherHistory::add_pub_change()` calls `clean_history()` and considers history full if it returns false. Actually remove items from history, and return whether we actually removed anything.

for eProsima#34
  • Loading branch information
liamstask committed Apr 29, 2016
1 parent 94f565c commit f633fbe
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/fastrtps/rtps/writer/StatelessWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class StatelessWriter : public RTPSWriter
*/
inline size_t getMatchedReadersSize() const {return m_matched_readers.size();};

bool clean_history(unsigned int /*max = 0*/){ return false; }
bool clean_history(unsigned int max = 0);

private:
//Duration_t resendDataPeriod; //FIXME: Not used yet.
Expand Down
24 changes: 24 additions & 0 deletions src/cpp/rtps/writer/StatelessWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,31 @@ void StatelessWriter::unsent_changes_reset()
//}


bool StatelessWriter::clean_history(unsigned int max)
{
boost::lock_guard<boost::recursive_mutex> guard(*mp_mutex);

bool removed = false;
if (max == 0) {
max = mp_history->getHistorySize();
}

while (max--) {
CacheChange_t *cc;
if (!mp_history->get_min_change(&cc)) {
break;
}
if (mp_history->remove_change(cc)) {
removed = true;
}
}

if (removed) {
unsent_changes_reset();
}

return removed;
}



Expand Down

0 comments on commit f633fbe

Please sign in to comment.