diff options
author | Tom Rondeau | 2011-01-02 13:49:08 -0500 |
---|---|---|
committer | Tom Rondeau | 2011-01-02 13:49:08 -0500 |
commit | 6925ccc667c8278c7b250fb4f7225e01680c62ea (patch) | |
tree | 11eb67b26265ca51d23732ab33749cf9adf716b0 /gnuradio-core/src | |
parent | 9c0bfe8920ec66b5b9f1f287d63ee66b4d208862 (diff) | |
download | gnuradio-6925ccc667c8278c7b250fb4f7225e01680c62ea.tar.gz gnuradio-6925ccc667c8278c7b250fb4f7225e01680c62ea.tar.bz2 gnuradio-6925ccc667c8278c7b250fb4f7225e01680c62ea.zip |
Going back to iterators for use in erasing items from the deque.
Diffstat (limited to 'gnuradio-core/src')
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_buffer.cc | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/gnuradio-core/src/lib/runtime/gr_buffer.cc b/gnuradio-core/src/lib/runtime/gr_buffer.cc index da1d8b542..3c935b960 100644 --- a/gnuradio-core/src/lib/runtime/gr_buffer.cc +++ b/gnuradio-core/src/lib/runtime/gr_buffer.cc @@ -243,13 +243,23 @@ gr_buffer::prune_tags(uint64_t max_time) buffer's mutex al la the scoped_lock line below. */ //gruel::scoped_lock guard(*mutex()); + std::deque<pmt::pmt_t>::iterator itr = d_item_tags.begin(); uint64_t item_time; - for(size_t i = 0; i < d_item_tags.size(); i++) { - item_time = pmt::pmt_to_uint64(pmt::pmt_tuple_ref(d_item_tags[i], 0)); + + // Since tags are not guarenteed to be in any particular order, + // we need to erase here instead of pop_front. An erase in the + // middle invalidates all iterators; so this resets the iterator + // to find more. Mostly, we wil be erasing from the front and + // therefore lose little time this way. + while(itr != d_item_tags.end()) { + item_time = pmt::pmt_to_uint64(pmt::pmt_tuple_ref(*itr, 0)); if(item_time < max_time) { - d_item_tags.pop_front(); + d_item_tags.erase(itr); + itr = d_item_tags.begin(); } + else + itr++; } } |