diff options
author | Nate Goergen <nate.goergen.gitlab1@mile10.com> | 2015-03-19 12:12:10 -0400 |
---|---|---|
committer | Tom Rondeau <tom@trondeau.com> | 2015-04-02 15:38:58 -0700 |
commit | 1a773a2411fa18455d2e995060fa2e9f42afc007 (patch) | |
tree | 836bd3c93b5036f3e495c6132f874a05906b9cff /gr-blocks/lib/ctrlport_probe2_c_impl.cc | |
parent | 91459f9b06500ac16f555819ef3c20f2029483c8 (diff) |
controlport: cleaner, more robust interface for buffer gets.
Diffstat (limited to 'gr-blocks/lib/ctrlport_probe2_c_impl.cc')
-rw-r--r-- | gr-blocks/lib/ctrlport_probe2_c_impl.cc | 31 |
1 files changed, 6 insertions, 25 deletions
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; } |