Created
August 5, 2015 19:06
-
-
Save trondeau/5ec12d06946af7b36faf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/gnuradio-runtime/lib/buffer.cc b/gnuradio-runtime/lib/buffer.cc | |
index f00e9a0..a0172b7 100644 | |
--- a/gnuradio-runtime/lib/buffer.cc | |
+++ b/gnuradio-runtime/lib/buffer.cc | |
@@ -248,11 +248,34 @@ namespace gr { | |
locks the mutex itself. | |
If this function is used elsewhere, remember to lock the | |
- buffer's mutex al la the scoped_lock line below. | |
+ buffer's mutex al la the scoped_lock: | |
+ gr::thread::scoped_lock guard(*mutex()); | |
*/ | |
- std::multimap<uint64_t, tag_t>::iterator end_itr = d_item_tags.lower_bound(max_time); | |
- std::multimap<uint64_t, tag_t>::iterator begin_itr = d_item_tags.begin(); | |
- d_item_tags.erase(begin_itr, end_itr); | |
+ | |
+ | |
+ /* | |
+ http://www.cplusplus.com/reference/map/multimap/erase/ | |
+ "Iterators, pointers and references referring to elements removed | |
+ by the function are invalidated. All other iterators, pointers | |
+ and references keep their validity." | |
+ | |
+ Store the iterator to be deleted in tmp; increment itr to the | |
+ next valid iterator, then erase tmp, which now becomes invalid. | |
+ */ | |
+ | |
+ uint64_t item_time; | |
+ std::multimap<uint64_t,tag_t>::iterator itr(d_item_tags.begin()), tmp; | |
+ while(itr != d_item_tags.end()) { | |
+ item_time = (*itr).second.offset; | |
+ if(item_time+d_max_reader_delay + bufsize() < max_time) { | |
+ tmp = itr; | |
+ itr++; | |
+ d_item_tags.erase(tmp); | |
+ } | |
+ else { | |
+ itr++; | |
+ } | |
+ } | |
} | |
long |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment