diff options
author | Johnathan Corgan <johnathan@corganlabs.com> | 2017-08-27 10:17:37 -0700 |
---|---|---|
committer | Johnathan Corgan <johnathan@corganlabs.com> | 2017-08-27 10:17:37 -0700 |
commit | ec71327d2949649866d85b1b80356481693ca38e (patch) | |
tree | c8cce2d2cce9de58f87d343967697dfe20dc6e48 | |
parent | 0500e4da92d85fdb6d2ea7d5ec4e76e186590052 (diff) | |
parent | b0699f7dc6b7e6ed278749ee03245225db8d2a7a (diff) |
Merge remote-tracking branch 'github/pr/1445' into maint
-rw-r--r-- | gr-blocks/lib/vector_sink_X_impl.cc.t | 17 | ||||
-rw-r--r-- | gr-blocks/lib/vector_sink_X_impl.h.t | 6 |
2 files changed, 20 insertions, 3 deletions
diff --git a/gr-blocks/lib/vector_sink_X_impl.cc.t b/gr-blocks/lib/vector_sink_X_impl.cc.t index 62c6d17dc7..3155c0cb67 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 Free Software Foundation, Inc. + * Copyright 2004,2008,2010,2013,2017 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -28,6 +28,7 @@ #include <@NAME_IMPL@.h> #include <gnuradio/io_signature.h> +#include <gnuradio/thread/thread.h> #include <algorithm> #include <iostream> @@ -55,15 +56,26 @@ namespace gr { std::vector<@TYPE@> @NAME_IMPL@::data() const { + gr::thread::scoped_lock guard(d_data_mutex); return d_data; } std::vector<tag_t> @NAME_IMPL@::tags() const { + gr::thread::scoped_lock guard(d_data_mutex); return d_tags; } + + void + @NAME_IMPL@::reset() + { + gr::thread::scoped_lock guard(d_data_mutex); + d_tags.clear(); + d_data.clear(); + } + int @NAME_IMPL@::work(int noutput_items, gr_vector_const_void_star &input_items, @@ -71,6 +83,9 @@ namespace gr { { @TYPE@ *iptr = (@TYPE@*)input_items[0]; + // can't touch this (as long as work() is working, the accessors shall not + // read the data + gr::thread::scoped_lock guard(d_data_mutex); for(int i = 0; i < noutput_items * d_vlen; i++) d_data.push_back (iptr[i]); std::vector<tag_t> tags; diff --git a/gr-blocks/lib/vector_sink_X_impl.h.t b/gr-blocks/lib/vector_sink_X_impl.h.t index 86f0e8773c..bf4811dfde 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 Free Software Foundation, Inc. + * Copyright 2004,2008,2009,2013,2017 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -26,6 +26,7 @@ #define @GUARD_NAME_IMPL@ #include <gnuradio/blocks/@NAME@.h> +#include <gnuradio/thread/thread.h> namespace gr { namespace blocks { @@ -35,13 +36,14 @@ namespace gr { private: std::vector<@TYPE@> d_data; std::vector<tag_t> d_tags; + mutable gr::thread::mutex d_data_mutex; // protects internal data access. int d_vlen; public: @NAME_IMPL@(int vlen); ~@NAME_IMPL@(); - void reset() { d_data.clear(); d_tags.clear(); } + void reset(); std::vector<@TYPE@> data() const; std::vector<tag_t> tags() const; |