From 05c2b1b544b76babbdb0210ae6a8d5de19e247bb Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 5 Feb 2011 00:05:30 -0800 Subject: udp: simplfy zero copy asio overhead with less shared_from_this, and timed waits when not needed --- host/include/uhd/transport/bounded_buffer.hpp | 9 ++++++++- host/include/uhd/transport/bounded_buffer.ipp | 11 ++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'host/include') diff --git a/host/include/uhd/transport/bounded_buffer.hpp b/host/include/uhd/transport/bounded_buffer.hpp index aca93b071..33ded8cfd 100644 --- a/host/include/uhd/transport/bounded_buffer.hpp +++ b/host/include/uhd/transport/bounded_buffer.hpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 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 @@ -65,6 +65,13 @@ namespace uhd{ namespace transport{ */ virtual bool push_with_timed_wait(const elem_type &elem, double timeout) = 0; + /*! + * Pop an element from the bounded_buffer immediately. + * \param elem the element reference pop to + * \return false when the bounded_buffer is empty + */ + virtual bool pop_with_haste(elem_type &elem) = 0; + /*! * Pop an element from the bounded_buffer. * Wait until the bounded_buffer becomes non-empty. diff --git a/host/include/uhd/transport/bounded_buffer.ipp b/host/include/uhd/transport/bounded_buffer.ipp index 4fbe3f085..7bf182ee3 100644 --- a/host/include/uhd/transport/bounded_buffer.ipp +++ b/host/include/uhd/transport/bounded_buffer.ipp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2011 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 @@ -72,6 +72,15 @@ namespace uhd{ namespace transport{ namespace{ /*anon*/ return true; } + UHD_INLINE bool pop_with_haste(elem_type &elem){ + boost::mutex::scoped_lock lock(_mutex); + if(_buffer.empty()) return false; + elem = this->pop_back(); + lock.unlock(); + _full_cond.notify_one(); + return true; + } + UHD_INLINE void pop_with_wait(elem_type &elem){ boost::mutex::scoped_lock lock(_mutex); _empty_cond.wait(lock, _not_empty_fcn); -- cgit v1.2.3