diff options
author | Josh Blum <josh@joshknows.com> | 2011-02-05 00:05:30 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-02-05 00:05:30 -0800 |
commit | 05c2b1b544b76babbdb0210ae6a8d5de19e247bb (patch) | |
tree | 98cbe5d5ecc3146cd0fae0c2f6a90b97f0bd8c8d /host/include | |
parent | 6c145193a955cfd6295b11bed3cc7cc9828feb9c (diff) | |
download | uhd-05c2b1b544b76babbdb0210ae6a8d5de19e247bb.tar.gz uhd-05c2b1b544b76babbdb0210ae6a8d5de19e247bb.tar.bz2 uhd-05c2b1b544b76babbdb0210ae6a8d5de19e247bb.zip |
udp: simplfy zero copy asio overhead with less shared_from_this, and timed waits when not needed
Diffstat (limited to 'host/include')
-rw-r--r-- | host/include/uhd/transport/bounded_buffer.hpp | 9 | ||||
-rw-r--r-- | host/include/uhd/transport/bounded_buffer.ipp | 11 |
2 files changed, 18 insertions, 2 deletions
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 @@ -66,6 +66,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. * \param elem the element reference pop to 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); |