Skip to content

Commit

Permalink
Updated CircularBuffer::updateDataItems() to skip orphaned dataItems …
Browse files Browse the repository at this point in the history
…instead of deleting them.
  • Loading branch information
mnoomnoo committed Mar 20, 2024
1 parent 65bc162 commit 8cddce6
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions src/mtconnect/buffer/circular_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,26 +85,12 @@ namespace mtconnect::buffer {
/// @param diMap the map of data item ids to new data item entities
void updateDataItems(std::unordered_map<std::string, WeakDataItemPtr> &diMap)
{
std::vector<boost::circular_buffer<observation::ObservationPtr>::iterator> orphanBufferItems;

auto iter = m_slidingBuffer.begin();
while( iter != m_slidingBuffer.end() )
for (auto &o : m_slidingBuffer)
{
observation::ObservationPtr o = *iter;
if( o->isOrphan() ) {
orphanBufferItems.push_back(iter);
}
else {
o->updateDataItem(diMap);
continue;
}
iter++;
}

// remove orphans from the slidingBuffer
while(!orphanBufferItems.empty()) {
auto orphanIterIter = orphanBufferItems.back();
m_slidingBuffer.erase(orphanIterIter);
orphanBufferItems.pop_back();
o->updateDataItem(diMap);
}

// checkpoints will remove orphans from its observations
Expand Down

0 comments on commit 8cddce6

Please sign in to comment.