diff options
Diffstat (limited to 'gr-blocks/lib')
-rw-r--r-- | gr-blocks/lib/ctrlport_probe2_b_impl.cc | 31 | ||||
-rw-r--r-- | gr-blocks/lib/ctrlport_probe2_b_impl.h | 6 | ||||
-rw-r--r-- | gr-blocks/lib/ctrlport_probe2_c_impl.cc | 31 | ||||
-rw-r--r-- | gr-blocks/lib/ctrlport_probe2_c_impl.h | 7 | ||||
-rw-r--r-- | gr-blocks/lib/ctrlport_probe2_f_impl.cc | 32 | ||||
-rw-r--r-- | gr-blocks/lib/ctrlport_probe2_f_impl.h | 7 | ||||
-rw-r--r-- | gr-blocks/lib/ctrlport_probe2_i_impl.cc | 32 | ||||
-rw-r--r-- | gr-blocks/lib/ctrlport_probe2_i_impl.h | 7 | ||||
-rw-r--r-- | gr-blocks/lib/ctrlport_probe2_s_impl.cc | 31 | ||||
-rw-r--r-- | gr-blocks/lib/ctrlport_probe2_s_impl.h | 7 |
10 files changed, 41 insertions, 150 deletions
diff --git a/gr-blocks/lib/ctrlport_probe2_b_impl.cc b/gr-blocks/lib/ctrlport_probe2_b_impl.cc index e6e2570ea6..3cf2ae0167 100644 --- a/gr-blocks/lib/ctrlport_probe2_b_impl.cc +++ b/gr-blocks/lib/ctrlport_probe2_b_impl.cc @@ -63,26 +63,9 @@ namespace gr { ninput_items_required[i] = d_len; } - // boost::shared_mutex mutex_buffer; - // mutable boost::mutex mutex_notify; - // boost::condition_variable condition_buffer_ready; std::vector<signed char> - ctrlport_probe2_b_impl::get() - { - mutex_buffer.lock(); - d_buffer.clear(); - mutex_buffer.unlock(); - - // wait for condition - boost::mutex::scoped_lock lock(mutex_notify); - condition_buffer_ready.wait(lock); - - mutex_buffer.lock(); - std::vector<signed char> buf_copy = d_buffer; - assert(buf_copy.size() == d_len); - mutex_buffer.unlock(); - - return buf_copy; + ctrlport_probe2_b_impl::get() { + return buffered_get.get(); } void @@ -112,7 +95,6 @@ namespace gr { const char *in = (const char*)input_items[0]; // copy samples to get buffer if we need samples - mutex_buffer.lock(); if(d_buffer.size() < d_len) { // copy smaller of remaining buffer space and num inputs to work() int num_copy = std::min( (int)(d_len - d_buffer.size()), noutput_items ); @@ -121,13 +103,12 @@ namespace gr { for(int i = 0; i < num_copy; i++) { d_buffer.push_back(in[i]); } + } - // notify the waiting get() if we fill up the buffer - if(d_buffer.size() == d_len) { - condition_buffer_ready.notify_one(); - } + // notify the waiting get() if we fill up the buffer + if(d_buffer.size() == d_len) { + buffered_get.offer_data(d_buffer); } - mutex_buffer.unlock(); return noutput_items; } diff --git a/gr-blocks/lib/ctrlport_probe2_b_impl.h b/gr-blocks/lib/ctrlport_probe2_b_impl.h index 155dd4c23c..490af9b040 100644 --- a/gr-blocks/lib/ctrlport_probe2_b_impl.h +++ b/gr-blocks/lib/ctrlport_probe2_b_impl.h @@ -25,7 +25,7 @@ #include <gnuradio/blocks/ctrlport_probe2_b.h> #include <gnuradio/rpcregisterhelpers.h> -#include <boost/thread/shared_mutex.hpp> +#include <gnuradio/rpcbufferedget.h> namespace gr { namespace blocks { @@ -37,11 +37,9 @@ namespace gr { std::string d_desc; size_t d_len; unsigned int d_disp_mask; - boost::shared_mutex mutex_buffer; - mutable boost::mutex mutex_notify; - boost::condition_variable condition_buffer_ready; std::vector<signed char> d_buffer; + rpcbufferedget< std::vector<signed char> > buffered_get; public: ctrlport_probe2_b_impl(const std::string &id, const std::string &desc, diff --git a/gr-blocks/lib/ctrlport_probe2_c_impl.cc b/gr-blocks/lib/ctrlport_probe2_c_impl.cc index aa038c0765..bd43130be5 100644 --- a/gr-blocks/lib/ctrlport_probe2_c_impl.cc +++ b/gr-blocks/lib/ctrlport_probe2_c_impl.cc @@ -64,26 +64,9 @@ namespace gr { ninput_items_required[i] = d_len; } - // boost::shared_mutex mutex_buffer; - // mutable boost::mutex mutex_notify; - // boost::condition_variable condition_buffer_ready; std::vector<gr_complex> - ctrlport_probe2_c_impl::get() - { - mutex_buffer.lock(); - d_buffer.clear(); - mutex_buffer.unlock(); - - // wait for condition - boost::mutex::scoped_lock lock(mutex_notify); - condition_buffer_ready.wait(lock); - - mutex_buffer.lock(); - std::vector<gr_complex> buf_copy = d_buffer; - assert(buf_copy.size() == d_len); - mutex_buffer.unlock(); - - return buf_copy; + ctrlport_probe2_c_impl::get() { + return buffered_get.get(); } void @@ -113,7 +96,6 @@ namespace gr { const gr_complex *in = (const gr_complex*)input_items[0]; // copy samples to get buffer if we need samples - mutex_buffer.lock(); if(d_buffer.size() < d_len) { // copy smaller of remaining buffer space and num inputs to work() int num_copy = std::min( (int)(d_len - d_buffer.size()), noutput_items ); @@ -122,13 +104,12 @@ namespace gr { for(int i = 0; i < num_copy; i++) { d_buffer.push_back(in[i]); } + } - // notify the waiting get() if we fill up the buffer - if(d_buffer.size() == d_len) { - condition_buffer_ready.notify_one(); - } + // notify the waiting get() if we fill up the buffer + if(d_buffer.size() == d_len) { + buffered_get.offer_data(d_buffer); } - mutex_buffer.unlock(); return noutput_items; } diff --git a/gr-blocks/lib/ctrlport_probe2_c_impl.h b/gr-blocks/lib/ctrlport_probe2_c_impl.h index 15ff0f4ea2..fa74216202 100644 --- a/gr-blocks/lib/ctrlport_probe2_c_impl.h +++ b/gr-blocks/lib/ctrlport_probe2_c_impl.h @@ -25,7 +25,7 @@ #include <gnuradio/blocks/ctrlport_probe2_c.h> #include <gnuradio/rpcregisterhelpers.h> -#include <boost/thread/shared_mutex.hpp> +#include <gnuradio/rpcbufferedget.h> namespace gr { namespace blocks { @@ -37,11 +37,9 @@ namespace gr { std::string d_desc; size_t d_len; unsigned int d_disp_mask; - boost::shared_mutex mutex_buffer; - mutable boost::mutex mutex_notify; - boost::condition_variable condition_buffer_ready; std::vector<gr_complex> d_buffer; + rpcbufferedget< std::vector<gr_complex> > buffered_get; public: ctrlport_probe2_c_impl(const std::string &id, const std::string &desc, @@ -66,4 +64,3 @@ namespace gr { } /* namespace gr */ #endif /* INCLUDED_CTRLPORT_PROBE2_C_IMPL_H */ - diff --git a/gr-blocks/lib/ctrlport_probe2_f_impl.cc b/gr-blocks/lib/ctrlport_probe2_f_impl.cc index b53b2dc3cb..05d67da9dd 100644 --- a/gr-blocks/lib/ctrlport_probe2_f_impl.cc +++ b/gr-blocks/lib/ctrlport_probe2_f_impl.cc @@ -62,26 +62,9 @@ namespace gr { ninput_items_required[i] = d_len; } - // boost::shared_mutex mutex_buffer; - // mutable boost::mutex mutex_notify; - // boost::condition_variable condition_buffer_ready; std::vector<float> - ctrlport_probe2_f_impl::get() - { - mutex_buffer.lock(); - d_buffer.clear(); - mutex_buffer.unlock(); - - // wait for condition - boost::mutex::scoped_lock lock(mutex_notify); - condition_buffer_ready.wait(lock); - - mutex_buffer.lock(); - std::vector<float> buf_copy = d_buffer; - assert(buf_copy.size() == d_len); - mutex_buffer.unlock(); - - return buf_copy; + ctrlport_probe2_f_impl::get() { + return buffered_get.get(); } void @@ -111,7 +94,6 @@ namespace gr { const float *in = (const float*)input_items[0]; // copy samples to get buffer if we need samples - mutex_buffer.lock(); if(d_buffer.size() < d_len) { // copy smaller of remaining buffer space and num inputs to work() int num_copy = std::min( (int)(d_len - d_buffer.size()), noutput_items ); @@ -120,13 +102,13 @@ namespace gr { for(int i = 0; i < num_copy; i++) { d_buffer.push_back(in[i]); } + } - // notify the waiting get() if we fill up the buffer - if(d_buffer.size() == d_len) { - condition_buffer_ready.notify_one(); - } + + // notify the waiting get() if we fill up the buffer + if(d_buffer.size() == d_len) { + buffered_get.offer_data(d_buffer); } - mutex_buffer.unlock(); return noutput_items; } diff --git a/gr-blocks/lib/ctrlport_probe2_f_impl.h b/gr-blocks/lib/ctrlport_probe2_f_impl.h index a4aa099237..8d406db927 100644 --- a/gr-blocks/lib/ctrlport_probe2_f_impl.h +++ b/gr-blocks/lib/ctrlport_probe2_f_impl.h @@ -25,7 +25,7 @@ #include <gnuradio/blocks/ctrlport_probe2_f.h> #include <gnuradio/rpcregisterhelpers.h> -#include <boost/thread/shared_mutex.hpp> +#include <gnuradio/rpcbufferedget.h> namespace gr { namespace blocks { @@ -37,11 +37,9 @@ namespace gr { std::string d_desc; size_t d_len; unsigned int d_disp_mask; - boost::shared_mutex mutex_buffer; - mutable boost::mutex mutex_notify; - boost::condition_variable condition_buffer_ready; std::vector<float> d_buffer; + rpcbufferedget< std::vector<float> > buffered_get; public: ctrlport_probe2_f_impl(const std::string &id, const std::string &desc, @@ -66,4 +64,3 @@ namespace gr { } /* namespace gr */ #endif /* INCLUDED_CTRLPORT_PROBE2_F_IMPL_H */ - diff --git a/gr-blocks/lib/ctrlport_probe2_i_impl.cc b/gr-blocks/lib/ctrlport_probe2_i_impl.cc index 77dca2ad0d..086ebe7cf0 100644 --- a/gr-blocks/lib/ctrlport_probe2_i_impl.cc +++ b/gr-blocks/lib/ctrlport_probe2_i_impl.cc @@ -64,26 +64,9 @@ namespace gr { ninput_items_required[i] = d_len; } - // boost::shared_mutex mutex_buffer; - // mutable boost::mutex mutex_notify; - // boost::condition_variable condition_buffer_ready; std::vector<int> - ctrlport_probe2_i_impl::get() - { - mutex_buffer.lock(); - d_buffer.clear(); - mutex_buffer.unlock(); - - // wait for condition - boost::mutex::scoped_lock lock(mutex_notify); - condition_buffer_ready.wait(lock); - - mutex_buffer.lock(); - std::vector<int> buf_copy = d_buffer; - assert(buf_copy.size() == d_len); - mutex_buffer.unlock(); - - return buf_copy; + ctrlport_probe2_i_impl::get() { + return buffered_get.get(); } void @@ -111,9 +94,7 @@ namespace gr { gr_vector_void_star &output_items) { const int *in = (const int*)input_items[0]; - // copy samples to get buffer if we need samples - mutex_buffer.lock(); if(d_buffer.size() < d_len) { // copy smaller of remaining buffer space and num inputs to work() int num_copy = std::min( (int)(d_len - d_buffer.size()), noutput_items ); @@ -122,13 +103,12 @@ namespace gr { for(int i = 0; i < num_copy; i++) { d_buffer.push_back(in[i]); } + } - // notify the waiting get() if we fill up the buffer - if(d_buffer.size() == d_len) { - condition_buffer_ready.notify_one(); - } + // notify the waiting get() if we fill up the buffer + if(d_buffer.size() == d_len) { + buffered_get.offer_data(d_buffer); } - mutex_buffer.unlock(); return noutput_items; } diff --git a/gr-blocks/lib/ctrlport_probe2_i_impl.h b/gr-blocks/lib/ctrlport_probe2_i_impl.h index 06493ac23a..3a976550eb 100644 --- a/gr-blocks/lib/ctrlport_probe2_i_impl.h +++ b/gr-blocks/lib/ctrlport_probe2_i_impl.h @@ -25,7 +25,7 @@ #include <gnuradio/blocks/ctrlport_probe2_i.h> #include <gnuradio/rpcregisterhelpers.h> -#include <boost/thread/shared_mutex.hpp> +#include <gnuradio/rpcbufferedget.h> namespace gr { namespace blocks { @@ -37,11 +37,9 @@ namespace gr { std::string d_desc; size_t d_len; unsigned int d_disp_mask; - boost::shared_mutex mutex_buffer; - mutable boost::mutex mutex_notify; - boost::condition_variable condition_buffer_ready; std::vector<int> d_buffer; + rpcbufferedget< std::vector<int> > buffered_get; public: ctrlport_probe2_i_impl(const std::string &id, const std::string &desc, @@ -66,4 +64,3 @@ namespace gr { } /* namespace gr */ #endif /* INCLUDED_CTRLPORT_PROBE2_I_IMPL_H */ - diff --git a/gr-blocks/lib/ctrlport_probe2_s_impl.cc b/gr-blocks/lib/ctrlport_probe2_s_impl.cc index 6a4ade462c..d6a15faaef 100644 --- a/gr-blocks/lib/ctrlport_probe2_s_impl.cc +++ b/gr-blocks/lib/ctrlport_probe2_s_impl.cc @@ -64,26 +64,9 @@ namespace gr { ninput_items_required[i] = d_len; } - // boost::shared_mutex mutex_buffer; - // mutable boost::mutex mutex_notify; - // boost::condition_variable condition_buffer_ready; std::vector<short> - ctrlport_probe2_s_impl::get() - { - mutex_buffer.lock(); - d_buffer.clear(); - mutex_buffer.unlock(); - - // wait for condition - boost::mutex::scoped_lock lock(mutex_notify); - condition_buffer_ready.wait(lock); - - mutex_buffer.lock(); - std::vector<short> buf_copy = d_buffer; - assert(buf_copy.size() == d_len); - mutex_buffer.unlock(); - - return buf_copy; + ctrlport_probe2_s_impl::get() { + return buffered_get.get(); } void @@ -113,7 +96,6 @@ namespace gr { const short *in = (const short*)input_items[0]; // copy samples to get buffer if we need samples - mutex_buffer.lock(); if(d_buffer.size() < d_len) { // copy smaller of remaining buffer space and num inputs to work() int num_copy = std::min( (int)(d_len - d_buffer.size()), noutput_items ); @@ -122,13 +104,12 @@ namespace gr { for(int i = 0; i < num_copy; i++) { d_buffer.push_back(in[i]); } + } - // notify the waiting get() if we fill up the buffer - if(d_buffer.size() == d_len) { - condition_buffer_ready.notify_one(); - } + // notify the waiting get() if we fill up the buffer + if(d_buffer.size() == d_len) { + buffered_get.offer_data(d_buffer); } - mutex_buffer.unlock(); return noutput_items; } diff --git a/gr-blocks/lib/ctrlport_probe2_s_impl.h b/gr-blocks/lib/ctrlport_probe2_s_impl.h index 078dd56b73..49533ced6f 100644 --- a/gr-blocks/lib/ctrlport_probe2_s_impl.h +++ b/gr-blocks/lib/ctrlport_probe2_s_impl.h @@ -25,7 +25,7 @@ #include <gnuradio/blocks/ctrlport_probe2_s.h> #include <gnuradio/rpcregisterhelpers.h> -#include <boost/thread/shared_mutex.hpp> +#include <gnuradio/rpcbufferedget.h> namespace gr { namespace blocks { @@ -37,11 +37,9 @@ namespace gr { std::string d_desc; size_t d_len; unsigned int d_disp_mask; - boost::shared_mutex mutex_buffer; - mutable boost::mutex mutex_notify; - boost::condition_variable condition_buffer_ready; std::vector<short> d_buffer; + rpcbufferedget< std::vector<short> > buffered_get; public: ctrlport_probe2_s_impl(const std::string &id, const std::string &desc, @@ -66,4 +64,3 @@ namespace gr { } /* namespace gr */ #endif /* INCLUDED_CTRLPORT_PROBE2_S_IMPL_H */ - |