From 40d8c22e39e69bbd7a6e459a6022e3d0457672d2 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Fri, 17 Jun 2011 12:06:27 -0700 Subject: uhd: tweak for bounded buffer pop elem --- host/include/uhd/transport/bounded_buffer.ipp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/host/include/uhd/transport/bounded_buffer.ipp b/host/include/uhd/transport/bounded_buffer.ipp index 0d393ad64..9c24005b7 100644 --- a/host/include/uhd/transport/bounded_buffer.ipp +++ b/host/include/uhd/transport/bounded_buffer.ipp @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -27,7 +28,7 @@ namespace uhd{ namespace transport{ namespace{ /*anon*/ - template class bounded_buffer_detail{ + template class bounded_buffer_detail : boost::noncopyable{ public: bounded_buffer_detail(size_t capacity): @@ -87,7 +88,7 @@ namespace uhd{ namespace transport{ namespace{ /*anon*/ UHD_INLINE bool pop_with_haste(elem_type &elem){ boost::mutex::scoped_lock lock(_mutex); if (_buffer.empty()) return false; - elem = this->pop_back(); + this->pop_back(elem); lock.unlock(); _full_cond.notify_one(); return true; @@ -97,7 +98,7 @@ namespace uhd{ namespace transport{ namespace{ /*anon*/ if (this->pop_with_haste(elem)) return; boost::mutex::scoped_lock lock(_mutex); _empty_cond.wait(lock, _not_empty_fcn); - elem = this->pop_back(); + this->pop_back(elem); lock.unlock(); _full_cond.notify_one(); } @@ -108,7 +109,7 @@ namespace uhd{ namespace transport{ namespace{ /*anon*/ if (not _empty_cond.timed_wait( lock, to_time_dur(timeout), _not_empty_fcn )) return false; - elem = this->pop_back(); + this->pop_back(elem); lock.unlock(); _full_cond.notify_one(); return true; @@ -130,11 +131,10 @@ namespace uhd{ namespace transport{ namespace{ /*anon*/ * 2) assign the back element to empty * 3) pop the back to move the counter */ - UHD_INLINE elem_type pop_back(void){ - elem_type elem = _buffer.back(); + UHD_INLINE void pop_back(elem_type &elem){ + elem = _buffer.back(); _buffer.back() = elem_type(); _buffer.pop_back(); - return elem; } static UHD_INLINE boost::posix_time::time_duration to_time_dur(double timeout){ -- cgit v1.2.3