summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Rondeau2010-11-17 15:58:49 -0800
committerTom Rondeau2010-11-17 15:58:49 -0800
commit6d4393613a78417b91e67af33820748ad3483e61 (patch)
tree4b84a0bb485108df94004393a201da14d8cc7879
parent97b1f1aa7d646fbc1250158ec94fe49d0979809c (diff)
downloadgnuradio-6d4393613a78417b91e67af33820748ad3483e61.tar.gz
gnuradio-6d4393613a78417b91e67af33820748ad3483e61.tar.bz2
gnuradio-6d4393613a78417b91e67af33820748ad3483e61.zip
Changing get_tags API to take in a vector reference instead of returning a vector.
-rw-r--r--gnuradio-core/src/lib/runtime/gr_block.cc14
-rw-r--r--gnuradio-core/src/lib/runtime/gr_block.h18
-rw-r--r--gnuradio-core/src/lib/runtime/gr_block_detail.cc22
-rw-r--r--gnuradio-core/src/lib/runtime/gr_block_detail.h19
-rw-r--r--gnuradio-core/src/lib/runtime/gr_block_executor.cc28
-rw-r--r--gnuradio-core/src/lib/runtime/gr_block_executor.h2
-rw-r--r--gnuradio-core/src/lib/runtime/gr_buffer.cc11
-rw-r--r--gnuradio-core/src/lib/runtime/gr_buffer.h6
8 files changed, 72 insertions, 48 deletions
diff --git a/gnuradio-core/src/lib/runtime/gr_block.cc b/gnuradio-core/src/lib/runtime/gr_block.cc
index 778344769..52be37e3b 100644
--- a/gnuradio-core/src/lib/runtime/gr_block.cc
+++ b/gnuradio-core/src/lib/runtime/gr_block.cc
@@ -152,19 +152,21 @@ gr_block::add_item_tag(unsigned int which_output,
d_detail->add_item_tag(which_output, offset, key, value, srcid);
}
-std::vector<pmt::pmt_t>
-gr_block::get_tags_in_range(unsigned int which_output,
+void
+gr_block::get_tags_in_range(std::vector<pmt::pmt_t> &v,
+ unsigned int which_output,
uint64_t start, uint64_t end)
{
- return d_detail->get_tags_in_range(which_output, start, end);
+ d_detail->get_tags_in_range(v, which_output, start, end);
}
-std::vector<pmt::pmt_t>
-gr_block::get_tags_in_range(unsigned int which_output,
+void
+gr_block::get_tags_in_range(std::vector<pmt::pmt_t> &v,
+ unsigned int which_output,
uint64_t start, uint64_t end,
const pmt::pmt_t &key)
{
- return d_detail->get_tags_in_range(which_output, start, end, key);
+ d_detail->get_tags_in_range(v, which_output, start, end, key);
}
gr_block::TAG_PROPAGATION_POLICY
diff --git a/gnuradio-core/src/lib/runtime/gr_block.h b/gnuradio-core/src/lib/runtime/gr_block.h
index a717946d2..7caf3c34a 100644
--- a/gnuradio-core/src/lib/runtime/gr_block.h
+++ b/gnuradio-core/src/lib/runtime/gr_block.h
@@ -268,13 +268,15 @@ class gr_block : public gr_basic_block {
* Tags are tuples of:
* (item count, source id, key, value)
*
+ * \param v a vector reference to return tags into
* \param which_input an integer of which input stream to pull from
* \param abs_start a uint64 count of the start of the range of interest
* \param abs_end a uint64 count of the end of the range of interest
*/
- std::vector<pmt::pmt_t> get_tags_in_range(unsigned int which_input,
- uint64_t abs_start,
- uint64_t abs_end);
+ void get_tags_in_range(std::vector<pmt::pmt_t> &v,
+ unsigned int which_input,
+ uint64_t abs_start,
+ uint64_t abs_end);
/*!
* \brief Given a [start,end), returns a vector of all tags in the range
@@ -285,15 +287,17 @@ class gr_block : public gr_basic_block {
* Tags are tuples of:
* (item count, source id, key, value)
*
+ * \param v a vector reference to return tags into
* \param which_input an integer of which input stream to pull from
* \param abs_start a uint64 count of the start of the range of interest
* \param abs_end a uint64 count of the end of the range of interest
* \param key a PMT symbol key to filter only tags of this key
*/
- std::vector<pmt::pmt_t> get_tags_in_range(unsigned int which_input,
- uint64_t abs_start,
- uint64_t abs_end,
- const pmt::pmt_t &key);
+ void get_tags_in_range(std::vector<pmt::pmt_t> &v,
+ unsigned int which_input,
+ uint64_t abs_start,
+ uint64_t abs_end,
+ const pmt::pmt_t &key);
// These are really only for internal use, but leaving them public avoids
// having to work up an ever-varying list of friends
diff --git a/gnuradio-core/src/lib/runtime/gr_block_detail.cc b/gnuradio-core/src/lib/runtime/gr_block_detail.cc
index 4f3ffc8dc..a360240c0 100644
--- a/gnuradio-core/src/lib/runtime/gr_block_detail.cc
+++ b/gnuradio-core/src/lib/runtime/gr_block_detail.cc
@@ -169,25 +169,29 @@ gr_block_detail::add_item_tag(unsigned int which_output,
}
}
-std::vector<pmt_t>
-gr_block_detail::get_tags_in_range(unsigned int which_input,
+void
+gr_block_detail::get_tags_in_range(std::vector<pmt::pmt_t> &v,
+ unsigned int which_input,
uint64_t abs_start,
uint64_t abs_end)
{
// get from gr_buffer_reader's deque of tags
- return d_input[which_input]->get_tags_in_range(abs_start, abs_end);
+ d_input[which_input]->get_tags_in_range(v, abs_start, abs_end);
}
-std::vector<pmt_t>
-gr_block_detail::get_tags_in_range(unsigned int which_input,
+void
+gr_block_detail::get_tags_in_range(std::vector<pmt_t> &v,
+ unsigned int which_input,
uint64_t abs_start,
uint64_t abs_end,
const pmt_t &key)
{
- std::vector<pmt_t> found_items, found_items_by_key;
+ std::vector<pmt_t> found_items;
+
+ v.resize(0);
// get from gr_buffer_reader's deque of tags
- found_items = d_input[which_input]->get_tags_in_range(abs_start, abs_end);
+ d_input[which_input]->get_tags_in_range(found_items, abs_start, abs_end);
// Filter further by key name
pmt_t itemkey;
@@ -195,9 +199,7 @@ gr_block_detail::get_tags_in_range(unsigned int which_input,
for(itr = found_items.begin(); itr != found_items.end(); itr++) {
itemkey = pmt_tuple_ref(*itr, 2);
if(pmt_eqv(key, itemkey)) {
- found_items_by_key.push_back(*itr);
+ v.push_back(*itr);
}
}
-
- return found_items_by_key;
}
diff --git a/gnuradio-core/src/lib/runtime/gr_block_detail.h b/gnuradio-core/src/lib/runtime/gr_block_detail.h
index 5902d1559..834ef47f5 100644
--- a/gnuradio-core/src/lib/runtime/gr_block_detail.h
+++ b/gnuradio-core/src/lib/runtime/gr_block_detail.h
@@ -25,6 +25,7 @@
#include <gr_runtime_types.h>
#include <gr_tpb_detail.h>
+#include <gr_tag_info.h>
#include <stdexcept>
/*!
@@ -124,13 +125,15 @@ class gr_block_detail {
* Tags are tuples of:
* (item count, source id, key, value)
*
+ * \param v a vector reference to return tags into
* \param which_input an integer of which input stream to pull from
* \param abs_start a uint64 count of the start of the range of interest
* \param abs_end a uint64 count of the end of the range of interest
*/
- std::vector<pmt::pmt_t> get_tags_in_range(unsigned int which_input,
- uint64_t abs_start,
- uint64_t abs_end);
+ void get_tags_in_range(std::vector<pmt::pmt_t> &v,
+ unsigned int which_input,
+ uint64_t abs_start,
+ uint64_t abs_end);
/*!
* \brief Given a [start,end), returns a vector of all tags in the range
@@ -143,15 +146,17 @@ class gr_block_detail {
* Tags are tuples of:
* (item count, source id, key, value)
*
+ * \param v a vector reference to return tags into
* \param which_input an integer of which input stream to pull from
* \param abs_start a uint64 count of the start of the range of interest
* \param abs_end a uint64 count of the end of the range of interest
* \param key a PMT symbol to select only tags of this key
*/
- std::vector<pmt::pmt_t> get_tags_in_range(unsigned int which_input,
- uint64_t abs_start,
- uint64_t abs_end,
- const pmt::pmt_t &key);
+ void get_tags_in_range(std::vector<pmt::pmt_t> &v,
+ unsigned int which_input,
+ uint64_t abs_start,
+ uint64_t abs_end,
+ const pmt::pmt_t &key);
gr_tpb_detail d_tpb; // used by thread-per-block scheduler
int d_produce_or;
diff --git a/gnuradio-core/src/lib/runtime/gr_block_executor.cc b/gnuradio-core/src/lib/runtime/gr_block_executor.cc
index 9882c2e5d..59799069a 100644
--- a/gnuradio-core/src/lib/runtime/gr_block_executor.cc
+++ b/gnuradio-core/src/lib/runtime/gr_block_executor.cc
@@ -89,7 +89,8 @@ min_available_space (gr_block_detail *d, int output_multiple)
static bool
propagate_tags(gr_block::TAG_PROPAGATION_POLICY policy, gr_block_detail *d,
- const std::vector<uint64_t> &start_nitems_read, double rrate)
+ const std::vector<uint64_t> &start_nitems_read, double rrate,
+ std::vector<pmt::pmt_t> &rtags)
{
// Move tags downstream
// if a sink, we don't need to move downstream;
@@ -105,10 +106,11 @@ propagate_tags(gr_block::TAG_PROPAGATION_POLICY policy, gr_block_detail *d,
case(gr_block::TPP_ALL_TO_ALL):
// every tag on every input propogates to everyone downstream
for(int i = 0; i < d->ninputs(); i++) {
- std::vector<pmt::pmt_t> tuple = d->get_tags_in_range(i, start_nitems_read[i],
- d->nitems_read(i));
+ d->get_tags_in_range(rtags, i, start_nitems_read[i],
+ d->nitems_read(i));
+
std::vector<pmt::pmt_t>::iterator t;
- for(t = tuple.begin(); t != tuple.end(); t++ ) {
+ for(t = rtags.begin(); t != rtags.end(); t++) {
uint64_t newcount = pmt::pmt_to_uint64(pmt::pmt_tuple_ref(*t, 0));
pmt::pmt_t newtup = pmt::mp(pmt::pmt_from_uint64(newcount * rrate),
pmt::pmt_tuple_ref(*t, 1),
@@ -117,7 +119,6 @@ propagate_tags(gr_block::TAG_PROPAGATION_POLICY policy, gr_block_detail *d,
for(int o = 0; o < d->noutputs(); o++)
d->output(o)->add_item_tag(newtup);
- //d->output(o)->add_item_tag(*t);
}
}
break;
@@ -127,11 +128,17 @@ propagate_tags(gr_block::TAG_PROPAGATION_POLICY policy, gr_block_detail *d,
// type of tag-propagation system is selected in gr_block_detail
if(d->ninputs() == d->noutputs()) {
for(int i = 0; i < d->ninputs(); i++) {
- std::vector<pmt::pmt_t> tuple = d->get_tags_in_range(i, start_nitems_read[i],
- d->nitems_read(i));
+ d->get_tags_in_range(rtags, i, start_nitems_read[i],
+ d->nitems_read(i));
+
std::vector<pmt::pmt_t>::iterator t;
- for(t = tuple.begin(); t != tuple.end(); t++ ) {
- d->output(i)->add_item_tag(*t);
+ for(t = rtags.begin(); t != rtags.end(); t++) {
+ uint64_t newcount = pmt::pmt_to_uint64(pmt::pmt_tuple_ref(*t, 0));
+ pmt::pmt_t newtup = pmt::mp(pmt::pmt_from_uint64(newcount * rrate),
+ pmt::pmt_tuple_ref(*t, 1),
+ pmt::pmt_tuple_ref(*t, 2),
+ pmt::pmt_tuple_ref(*t, 3));
+ d->output(i)->add_item_tag(newtup);
}
}
}
@@ -366,7 +373,8 @@ gr_block_executor::run_one_iteration()
<< " result = " << n << std::endl);
if(!propagate_tags(m->tag_propagation_policy(), d,
- d_start_nitems_read, m->relative_rate()))
+ d_start_nitems_read, m->relative_rate(),
+ d_returned_tags))
goto were_done;
if (n == gr_block::WORK_DONE)
diff --git a/gnuradio-core/src/lib/runtime/gr_block_executor.h b/gnuradio-core/src/lib/runtime/gr_block_executor.h
index 22b782883..77ace5522 100644
--- a/gnuradio-core/src/lib/runtime/gr_block_executor.h
+++ b/gnuradio-core/src/lib/runtime/gr_block_executor.h
@@ -25,6 +25,7 @@
#include <gr_runtime_types.h>
#include <fstream>
+#include <gruel/pmt.h>
//class gr_block_executor;
//typedef boost::shared_ptr<gr_block_executor> gr_block_executor_sptr;
@@ -48,6 +49,7 @@ protected:
std::vector<bool> d_input_done;
gr_vector_void_star d_output_items;
std::vector<uint64_t> d_start_nitems_read; //stores where tag counts are before work
+ std::vector<pmt::pmt_t> d_returned_tags;
public:
gr_block_executor(gr_block_sptr block);
diff --git a/gnuradio-core/src/lib/runtime/gr_buffer.cc b/gnuradio-core/src/lib/runtime/gr_buffer.cc
index 84a65f921..70d57c094 100644
--- a/gnuradio-core/src/lib/runtime/gr_buffer.cc
+++ b/gnuradio-core/src/lib/runtime/gr_buffer.cc
@@ -271,13 +271,14 @@ gr_buffer_reader::update_read_pointer (int nitems)
d_abs_read_offset += nitems;
}
-std::vector<pmt::pmt_t>
-gr_buffer_reader::get_tags_in_range(uint64_t abs_start,
+void
+gr_buffer_reader::get_tags_in_range(std::vector<pmt::pmt_t> &v,
+ uint64_t abs_start,
uint64_t abs_end)
{
gruel::scoped_lock guard(*mutex());
- std::vector<pmt::pmt_t> found_items;
+ v.resize(0);
std::deque<pmt::pmt_t>::iterator itr = d_buffer->get_tags_begin();
uint64_t item_time;
@@ -285,13 +286,11 @@ gr_buffer_reader::get_tags_in_range(uint64_t abs_start,
item_time = pmt::pmt_to_uint64(pmt::pmt_tuple_ref(*itr, 0));
if((item_time >= abs_start) && (item_time <= abs_end)) {
- found_items.push_back(*itr);
+ v.push_back(*itr);
}
itr++;
}
-
- return found_items;
}
void
diff --git a/gnuradio-core/src/lib/runtime/gr_buffer.h b/gnuradio-core/src/lib/runtime/gr_buffer.h
index 47ba4cd96..88a76fdc6 100644
--- a/gnuradio-core/src/lib/runtime/gr_buffer.h
+++ b/gnuradio-core/src/lib/runtime/gr_buffer.h
@@ -255,11 +255,13 @@ class gr_buffer_reader {
* Tags are tuples of:
* (item count, source id, key, value)
*
+ * \param v a vector reference to return tags into
* \param abs_start a uint64 count of the start of the range of interest
* \param abs_end a uint64 count of the end of the range of interest
*/
- std::vector<pmt::pmt_t> get_tags_in_range(uint64_t abs_start,
- uint64_t abs_end);
+ void get_tags_in_range(std::vector<pmt::pmt_t> &v,
+ uint64_t abs_start,
+ uint64_t abs_end);
void prune_tags(uint64_t max_time);