From f1108bd25a369a83ef8227c7564e812d4e27f369 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 2 Apr 2013 10:22:34 -0700 Subject: uhd: switch the reusable barrier to condition variables This allows the converter threads in a multi-threaded streamer to wait quietly. In addition, the use of two barriers in the packet handlers was reduced to one, by adding a simple exit barrier inside the reusable barrier's wait method. --- host/lib/transport/super_recv_packet_handler.hpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'host/lib/transport/super_recv_packet_handler.hpp') diff --git a/host/lib/transport/super_recv_packet_handler.hpp b/host/lib/transport/super_recv_packet_handler.hpp index 7a1972690..5a75d5f0d 100644 --- a/host/lib/transport/super_recv_packet_handler.hpp +++ b/host/lib/transport/super_recv_packet_handler.hpp @@ -1,5 +1,5 @@ // -// Copyright 2011-2012 Ettus Research LLC +// Copyright 2011-2013 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -79,8 +79,7 @@ public: } ~recv_packet_handler(void){ - _task_barrier_entry.interrupt(); - _task_barrier_exit.interrupt(); + _task_barrier.interrupt(); _task_handlers.clear(); } @@ -91,8 +90,7 @@ public: _props.resize(size); //re-initialize all buffers infos by re-creating the vector _buffers_infos = std::vector(4, buffers_info_type(size)); - _task_barrier_entry.resize(size); - _task_barrier_exit.resize(size); + _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(&recv_packet_handler::converter_thread_task, this, i)); @@ -561,7 +559,7 @@ private: ******************************************************************/ UHD_INLINE void converter_thread_task(const size_t index) { - _task_barrier_entry.wait(); + _task_barrier.wait(); //shortcut references to local data structures buffers_info_type &buff_info = get_curr_buffer_info(); @@ -587,11 +585,11 @@ private: info.buff.reset(); //effectively a release } - _task_barrier_exit.wait(); + if (index == 0) _task_barrier.wait_others(); } //! Shared variables for the worker threads - reusable_barrier _task_barrier_entry, _task_barrier_exit; + reusable_barrier _task_barrier; std::vector _task_handlers; size_t _convert_nsamps; const rx_streamer::buffs_type *_convert_buffs; -- cgit v1.2.3