summaryrefslogtreecommitdiffstats
path: root/host/include
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-10-04 15:04:53 -0700
committerJosh Blum <josh@joshknows.com>2010-10-04 15:04:53 -0700
commite54aa5ba5a65698a106cc0852b856cab5cd8e767 (patch)
treee484ba7f9b0f81c3f13be776aff952c27ac8bb31 /host/include
parentb7d828b30bff1f2134319679137f99004f1d4b49 (diff)
parent5bd863efa05f3c6cfd672cffe87f57b33d1c32b5 (diff)
downloaduhd-e54aa5ba5a65698a106cc0852b856cab5cd8e767.tar.gz
uhd-e54aa5ba5a65698a106cc0852b856cab5cd8e767.tar.bz2
uhd-e54aa5ba5a65698a106cc0852b856cab5cd8e767.zip
Merge branch 'timeout' into usrp_e_mmap
Diffstat (limited to 'host/include')
-rw-r--r--host/include/uhd/transport/bounded_buffer.ipp16
1 files changed, 14 insertions, 2 deletions
diff --git a/host/include/uhd/transport/bounded_buffer.ipp b/host/include/uhd/transport/bounded_buffer.ipp
index 71143741e..58f78bab4 100644
--- a/host/include/uhd/transport/bounded_buffer.ipp
+++ b/host/include/uhd/transport/bounded_buffer.ipp
@@ -73,7 +73,7 @@ namespace uhd{ namespace transport{ namespace{ /*anon*/
UHD_INLINE void pop_with_wait(elem_type &elem){
boost::unique_lock<boost::mutex> lock(_mutex);
_empty_cond.wait(lock, boost::bind(&bounded_buffer_impl<elem_type>::not_empty, this));
- elem = _buffer.back(); _buffer.pop_back();
+ this->pop_back(elem);
lock.unlock();
_full_cond.notify_one();
}
@@ -84,7 +84,7 @@ namespace uhd{ namespace transport{ namespace{ /*anon*/
lock, boost::posix_time::microseconds(long(timeout*1e6)),
boost::bind(&bounded_buffer_impl<elem_type>::not_empty, this)
)) return false;
- elem = _buffer.back(); _buffer.pop_back();
+ this->pop_back(elem);
lock.unlock();
_full_cond.notify_one();
return true;
@@ -104,6 +104,18 @@ namespace uhd{ namespace transport{ namespace{ /*anon*/
bool not_full(void) const{return not _buffer.full();}
bool not_empty(void) const{return not _buffer.empty();}
+
+ /*!
+ * Three part operation to pop an element:
+ * 1) assign elem to the back element
+ * 2) assign the back element to empty
+ * 3) pop the back to move the counter
+ */
+ UHD_INLINE void pop_back(elem_type &elem){
+ elem = _buffer.back();
+ _buffer.back() = elem_type();
+ _buffer.pop_back();
+ }
};
}}} //namespace