Skip to content

Commit 8cddce6

Browse files
committed
Updated CircularBuffer::updateDataItems() to skip orphaned dataItems instead of deleting them.
1 parent 65bc162 commit 8cddce6

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

src/mtconnect/buffer/circular_buffer.hpp

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -85,26 +85,12 @@ namespace mtconnect::buffer {
8585
/// @param diMap the map of data item ids to new data item entities
8686
void updateDataItems(std::unordered_map<std::string, WeakDataItemPtr> &diMap)
8787
{
88-
std::vector<boost::circular_buffer<observation::ObservationPtr>::iterator> orphanBufferItems;
89-
90-
auto iter = m_slidingBuffer.begin();
91-
while( iter != m_slidingBuffer.end() )
88+
for (auto &o : m_slidingBuffer)
9289
{
93-
observation::ObservationPtr o = *iter;
9490
if( o->isOrphan() ) {
95-
orphanBufferItems.push_back(iter);
96-
}
97-
else {
98-
o->updateDataItem(diMap);
91+
continue;
9992
}
100-
iter++;
101-
}
102-
103-
// remove orphans from the slidingBuffer
104-
while(!orphanBufferItems.empty()) {
105-
auto orphanIterIter = orphanBufferItems.back();
106-
m_slidingBuffer.erase(orphanIterIter);
107-
orphanBufferItems.pop_back();
93+
o->updateDataItem(diMap);
10894
}
10995

11096
// checkpoints will remove orphans from its observations

0 commit comments

Comments
 (0)