summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrej Rode <mail@andrejro.de>2018-01-15 00:50:51 +0100
committerMarcus Müller <marcus.mueller@ettus.com>2018-02-17 22:58:07 +0100
commitcb278e1237f23271bafbb6b7f7cd5e5c47ee28d8 (patch)
tree73a1a8240591b40abedf80c1cdc010ad89646a02
parentcaa4e5d34daf8e27c6ae7ddf982ae25113a934e3 (diff)
blocks: reserve memory in vector_sink constructor
-rw-r--r--gr-blocks/grc/blocks_vector_sink_x.xml9
-rw-r--r--gr-blocks/include/gnuradio/blocks/vector_sink_X.h.t4
-rw-r--r--gr-blocks/lib/vector_sink_X_impl.cc.t10
-rw-r--r--gr-blocks/lib/vector_sink_X_impl.h.t4
4 files changed, 18 insertions, 9 deletions
diff --git a/gr-blocks/grc/blocks_vector_sink_x.xml b/gr-blocks/grc/blocks_vector_sink_x.xml
index 7f51731975..9c96ffb85a 100644
--- a/gr-blocks/grc/blocks_vector_sink_x.xml
+++ b/gr-blocks/grc/blocks_vector_sink_x.xml
@@ -8,7 +8,7 @@
<name>Vector Sink</name>
<key>blocks_vector_sink_x</key>
<import>from gnuradio import blocks</import>
- <make>blocks.vector_sink_$(type.fcn)($vlen)</make>
+ <make>blocks.vector_sink_$(type.fcn)($vlen, $reserve_items)</make>
<param>
<name>Input Type</name>
<key>type</key>
@@ -45,6 +45,13 @@
<value>1</value>
<type>int</type>
</param>
+ <param>
+ <name>Reserve memory for items</name>
+ <key>reserve_items</key>
+ <value>1024</value>
+ <type>int</type>
+ <hide>part</hide>
+ </param>
<check>$vlen &gt; 0</check>
<sink>
<name>in</name>
diff --git a/gr-blocks/include/gnuradio/blocks/vector_sink_X.h.t b/gr-blocks/include/gnuradio/blocks/vector_sink_X.h.t
index a4ef38fd04..9a9faa469b 100644
--- a/gr-blocks/include/gnuradio/blocks/vector_sink_X.h.t
+++ b/gr-blocks/include/gnuradio/blocks/vector_sink_X.h.t
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2008,2009,2013 Free Software Foundation, Inc.
+ * Copyright 2004,2008,2009,2013,2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -41,7 +41,7 @@ namespace gr {
// gr::blocks::@NAME@::sptr
typedef boost::shared_ptr<@NAME@> sptr;
- static sptr make(int vlen = 1);
+ static sptr make(const int vlen = 1, const int reserve_items = 1024);
//! Clear the data and tags containers.
virtual void reset() = 0;
diff --git a/gr-blocks/lib/vector_sink_X_impl.cc.t b/gr-blocks/lib/vector_sink_X_impl.cc.t
index 3155c0cb67..630ddb9165 100644
--- a/gr-blocks/lib/vector_sink_X_impl.cc.t
+++ b/gr-blocks/lib/vector_sink_X_impl.cc.t
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2008,2010,2013,2017 Free Software Foundation, Inc.
+ * Copyright 2004,2008,2010,2013,2017-2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -36,18 +36,20 @@ namespace gr {
namespace blocks {
@NAME@::sptr
- @BASE_NAME@::make(int vlen)
+ @BASE_NAME@::make(const int vlen, const int reserve_items)
{
return gnuradio::get_initial_sptr
- (new @NAME_IMPL@(vlen));
+ (new @NAME_IMPL@(vlen, reserve_items));
}
- @NAME_IMPL@::@NAME_IMPL@(int vlen)
+ @NAME_IMPL@::@NAME_IMPL@(const int vlen, const int reserve_items)
: sync_block("@NAME@",
io_signature::make(1, 1, sizeof(@TYPE@) * vlen),
io_signature::make(0, 0, 0)),
d_vlen(vlen)
{
+ gr::thread::scoped_lock guard(d_data_mutex);
+ d_data.reserve(d_vlen * reserve_items);
}
@NAME_IMPL@::~@NAME_IMPL@()
diff --git a/gr-blocks/lib/vector_sink_X_impl.h.t b/gr-blocks/lib/vector_sink_X_impl.h.t
index bf4811dfde..dfcb2ccc04 100644
--- a/gr-blocks/lib/vector_sink_X_impl.h.t
+++ b/gr-blocks/lib/vector_sink_X_impl.h.t
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2008,2009,2013,2017 Free Software Foundation, Inc.
+ * Copyright 2004,2008,2009,2013,2017-2018 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -40,7 +40,7 @@ namespace gr {
int d_vlen;
public:
- @NAME_IMPL@(int vlen);
+ @NAME_IMPL@(const int vlen, const int reserve_items);
~@NAME_IMPL@();
void reset();