From 68a743ef30c546870b4485c25de7486e5b67a56d Mon Sep 17 00:00:00 2001
From: Paul David <paul.david@ettus.com>
Date: Wed, 18 May 2016 13:26:29 -0700
Subject: transport: Removing task barrier for conversion calls in the
 super_send_packet_handler

---
 host/lib/transport/super_send_packet_handler.hpp | 35 +++++++++---------------
 1 file changed, 13 insertions(+), 22 deletions(-)

(limited to 'host/lib/transport')

diff --git a/host/lib/transport/super_send_packet_handler.hpp b/host/lib/transport/super_send_packet_handler.hpp
index c2810842e..a6b9b12d0 100644
--- a/host/lib/transport/super_send_packet_handler.hpp
+++ b/host/lib/transport/super_send_packet_handler.hpp
@@ -24,11 +24,11 @@
 #include <uhd/stream.hpp>
 #include <uhd/utils/msg.hpp>
 #include <uhd/utils/tasks.hpp>
-#include <uhd/utils/atomic.hpp>
 #include <uhd/utils/byteswap.hpp>
 #include <uhd/types/metadata.hpp>
 #include <uhd/transport/vrt_if_packet.hpp>
 #include <uhd/transport/zero_copy.hpp>
+#include <boost/thread/thread.hpp>
 #include <boost/thread/thread_time.hpp>
 #include <boost/foreach.hpp>
 #include <boost/function.hpp>
@@ -74,22 +74,15 @@ public:
     }
 
     ~send_packet_handler(void){
-        _task_barrier.interrupt();
-        _task_handlers.clear();
+        /* NOP */
     }
 
     //! Resize the number of transport channels
     void resize(const size_t size){
         if (this->size() == size) return;
-        _task_handlers.clear();
         _props.resize(size);
         static const boost::uint64_t zero = 0;
         _zero_buffs.resize(size, &zero);
-        _task_barrier.resize(size);
-        _task_handlers.resize(size);
-        for (size_t i = 1/*skip 0*/; i < size; i++){
-            _task_handlers[i] = task::make(boost::bind(&send_packet_handler::converter_thread_task, this, i));
-        };
     }
 
     //! Get the channel width of this handler
@@ -377,21 +370,23 @@ private:
         _convert_if_packet_info = &if_packet_info;
 
         //perform N channels of conversion
-        converter_thread_task(0);
+        for (size_t i = 0; i < buffs.size(); i++) {
+            convert_to_in_buff(i);
+        }
 
         _next_packet_seq++; //increment sequence after commits
         return nsamps_per_buff;
     }
 
-    /*******************************************************************
-     * Perform one thread's work of the conversion task.
-     * The entry and exit use a dual synchronization barrier,
-     * to wait for data to become ready and block until completion.
-     ******************************************************************/
-    UHD_INLINE void converter_thread_task(const size_t index)
+    /*! Run the conversion from the internal buffers to the user's input
+     *  buffer.
+     *
+     * - Calls the converter
+     * - Releases internal data buffers
+     * - Updates read/write pointers
+     */
+    UHD_INLINE void convert_to_in_buff(const size_t index)
     {
-        _task_barrier.wait();
-
         //shortcut references to local data structures
         managed_send_buffer::sptr &buff = _props[index].buff;
         vrt::if_packet_info_t if_packet_info = *_convert_if_packet_info;
@@ -419,13 +414,9 @@ private:
         const size_t num_vita_words32 = _header_offset_words32+if_packet_info.num_packet_words32;
         buff->commit(num_vita_words32*sizeof(boost::uint32_t));
         buff.reset(); //effectively a release
-
-        if (index == 0) _task_barrier.wait_others();
     }
 
     //! Shared variables for the worker threads
-    reusable_barrier _task_barrier;
-    std::vector<task::sptr> _task_handlers;
     size_t _convert_nsamps;
     const tx_streamer::buffs_type *_convert_buffs;
     size_t _convert_buffer_offset_bytes;
-- 
cgit v1.2.3