[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 06/22: tags_wip
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 06/22: tags_wip |
Date: |
Wed, 24 Sep 2014 22:07:38 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
trondeau pushed a commit to branch master
in repository gnuradio.
commit eccc0c792ba0a724c769b4ac4d7ffc3d7b277c7a
Author: Tim O'Shea <address@hidden>
Date: Fri Sep 19 09:40:04 2014 -0400
tags_wip
---
gnuradio-runtime/include/gnuradio/buffer.h | 7 +++--
gnuradio-runtime/lib/buffer.cc | 47 ++++++++++++++++++++----------
2 files changed, 36 insertions(+), 18 deletions(-)
diff --git a/gnuradio-runtime/include/gnuradio/buffer.h
b/gnuradio-runtime/include/gnuradio/buffer.h
index e2d5760..d40417e 100644
--- a/gnuradio-runtime/include/gnuradio/buffer.h
+++ b/gnuradio-runtime/include/gnuradio/buffer.h
@@ -125,8 +125,8 @@ namespace gr {
*/
void prune_tags(uint64_t max_time);
- std::deque<tag_t>::iterator get_tags_begin() { return d_item_tags.begin();
}
- std::deque<tag_t>::iterator get_tags_end() { return d_item_tags.end(); }
+ std::multimap<uint64_t,tag_t>::iterator get_tags_begin() { return
d_item_tags.begin(); }
+ std::multimap<uint64_t,tag_t>::iterator get_tags_end() { return
d_item_tags.end(); }
//
-------------------------------------------------------------------------
@@ -157,7 +157,8 @@ namespace gr {
unsigned int d_write_index; // in items
[0,d_bufsize)
uint64_t d_abs_write_offset; // num items
written since the start
bool d_done;
- std::deque<tag_t> d_item_tags;
+ std::multimap<uint64_t,tag_t> d_item_tags;
+ //std::deque<tag_t> d_item_tags;
uint64_t d_last_min_items_read;
unsigned index_add(unsigned a, unsigned b)
diff --git a/gnuradio-runtime/lib/buffer.cc b/gnuradio-runtime/lib/buffer.cc
index 162324e..346bb58 100644
--- a/gnuradio-runtime/lib/buffer.cc
+++ b/gnuradio-runtime/lib/buffer.cc
@@ -225,16 +225,19 @@ namespace gr {
buffer::add_item_tag(const tag_t &tag)
{
gr::thread::scoped_lock guard(*mutex());
- d_item_tags.push_back(tag);
+ d_item_tags.insert(std::pair<uint64_t,tag_t>(tag.offset,tag));
+ //d_item_tags.push_back(tag);
}
void
buffer::remove_item_tag(const tag_t &tag, long id)
{
gr::thread::scoped_lock guard(*mutex());
- for(std::deque<tag_t>::iterator it = d_item_tags.begin(); it !=
d_item_tags.end(); ++it) {
- if(*it == tag) {
- (*it).marked_deleted.push_back(id);
+// TODO: we can probably do this more efficiently now ...
+// for(std::deque<tag_t>::iterator it = d_item_tags.begin(); it !=
d_item_tags.end(); ++it) {
+ for(std::multimap<uint64_t,tag_t>::iterator it = d_item_tags.begin(); it
!= d_item_tags.end(); ++it) {
+ if((*it).second == tag) {
+ (*it).second.marked_deleted.push_back(id);
}
}
}
@@ -251,24 +254,37 @@ namespace gr {
buffer's mutex al la the scoped_lock line below.
*/
//gr::thread::scoped_lock guard(*mutex());
- std::deque<tag_t>::iterator itr = d_item_tags.begin();
+#if 0
+ for(size_t i=0; i<d_item_tags.size(); ){
+ const tag_t &tag = d_item_tags.at(i);
+ uint64_t item_time = tag.offset;
+ if(item_time+d_max_reader_delay + bufsize() < max_time) {
+ d_item_tags.erase(d_item_tags.begin()+i);
+ continue;
+ }
+ i++;
+ }
+#endif
+#if 1
+ std::multimap<uint64_t,tag_t>::iterator itr(d_item_tags.begin());
uint64_t item_time;
-
// 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
+ // more. Mostly, we will be erasing from the front and
// therefore lose little time this way.
while(itr != d_item_tags.end()) {
- item_time = (*itr).offset;
+ item_time = (*itr).second.offset;
if(item_time+d_max_reader_delay + bufsize() < max_time) {
- d_item_tags.erase(itr);
- itr = d_item_tags.begin();
+ //d_item_tags.erase(itr);
+ //itr = d_item_tags.begin();
+ itr++;
}
else
itr++;
}
+#endif
}
long
@@ -338,19 +354,20 @@ namespace gr {
gr::thread::scoped_lock guard(*mutex());
v.resize(0);
- std::deque<tag_t>::iterator itr = d_buffer->get_tags_begin();
+ std::multimap<uint64_t,tag_t>::iterator itr = d_buffer->get_tags_begin();
uint64_t item_time;
while(itr != d_buffer->get_tags_end()) {
- item_time = (*itr).offset + d_attr_delay;
+ item_time = (*itr).second.offset + d_attr_delay;
+ //item_time = (*itr).offset + d_attr_delay;
if((item_time >= abs_start) && (item_time < abs_end)) {
std::vector<long>::iterator id_itr;
- id_itr = std::find(itr->marked_deleted.begin(),
itr->marked_deleted.end(), id);
+ id_itr = std::find(itr->second.marked_deleted.begin(),
itr->second.marked_deleted.end(), id);
// If id is not in the vector of marked blocks
- if(id_itr == itr->marked_deleted.end()) {
- tag_t t = *itr;
+ if(id_itr == itr->second.marked_deleted.end()) {
+ tag_t t = (*itr).second;
t.offset += d_attr_delay;
v.push_back(t);
v.back().marked_deleted.clear();
- [Commit-gnuradio] [gnuradio] 08/22: Fix prune_tags, (continued)
- [Commit-gnuradio] [gnuradio] 08/22: Fix prune_tags, git, 2014/09/24
- [Commit-gnuradio] [gnuradio] 01/22: Add vector support to abs block. Remove unused num_inputs from xml., git, 2014/09/24
- [Commit-gnuradio] [gnuradio] 05/22: blocks: Added callback to vector source GRC bindings, git, 2014/09/24
- [Commit-gnuradio] [gnuradio] 07/22: Fix(?) prune_tags: needs verification, git, 2014/09/24
- [Commit-gnuradio] [gnuradio] 15/22: digital: clock recovery fix relative limit, git, 2014/09/24
- [Commit-gnuradio] [gnuradio] 21/22: Merge branch 'master' of git.gnuradio.org:gnuradio, git, 2014/09/24
- [Commit-gnuradio] [gnuradio] 13/22: fec: turning off some debug output., git, 2014/09/24
- [Commit-gnuradio] [gnuradio] 10/22: Formatting fix-ups, git, 2014/09/24
- [Commit-gnuradio] [gnuradio] 19/22: digital: applying same fix of the complex M&M clock recovery block as the float version., git, 2014/09/24
- [Commit-gnuradio] [gnuradio] 14/22: blocks: deinterleaver will process more than one block at a time for significant speed improvements., git, 2014/09/24
- [Commit-gnuradio] [gnuradio] 06/22: tags_wip,
git <=
- [Commit-gnuradio] [gnuradio] 22/22: Merge branch 'maint', git, 2014/09/24
- [Commit-gnuradio] [gnuradio] 09/22: runtime: speed up all the things, git, 2014/09/24
- [Commit-gnuradio] [gnuradio] 12/22: docs: fixed path stripping for binary dirs in doxygen manual., git, 2014/09/24
- [Commit-gnuradio] [gnuradio] 17/22: digital: clock recovery more verbose documentation, git, 2014/09/24
- [Commit-gnuradio] [gnuradio] 11/22: blocks: added example of how to construct and add a tag to a vector_source., git, 2014/09/24
- [Commit-gnuradio] [gnuradio] 18/22: digital: adapt clock recovery QA, git, 2014/09/24
- [Commit-gnuradio] [gnuradio] 16/22: digital: clock recovery delete unused variables, git, 2014/09/24
- [Commit-gnuradio] [gnuradio] 20/22: CID 1240027: runtime: clean up tag pruning using iter range, git, 2014/09/24