From ea5ce50a465e714c63196f52df97fb3e927e701c Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 14 May 2011 17:11:05 -0700 Subject: uhd: replace managed buffer shared pointer w/ intrusive pointer to reduce overhead --- host/lib/usrp/usrp1/io_impl.cpp | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'host/lib/usrp/usrp1/io_impl.cpp') diff --git a/host/lib/usrp/usrp1/io_impl.cpp b/host/lib/usrp/usrp1/io_impl.cpp index 7252ac587..8ac2696eb 100644 --- a/host/lib/usrp/usrp1/io_impl.cpp +++ b/host/lib/usrp/usrp1/io_impl.cpp @@ -61,39 +61,28 @@ class offset_managed_send_buffer : public managed_send_buffer{ public: typedef boost::function commit_cb_type; offset_managed_send_buffer(const commit_cb_type &commit_cb): - _expired(true), _commit_cb(commit_cb) + _commit_cb(commit_cb) { /* NOP */ } - bool expired(void){return _expired;} - void commit(size_t size){ - if (_expired) return; - this->_commit_cb(_curr_buff, _next_buff, size); - _expired = true; + if (size != 0) this->_commit_cb(_curr_buff, _next_buff, size); } sptr get_new( offset_send_buffer &curr_buff, offset_send_buffer &next_buff ){ - _expired = false; _curr_buff = curr_buff; _next_buff = next_buff; - return sptr(this, &offset_managed_send_buffer::fake_deleter); + return make_managed_buffer(this); } private: - static void fake_deleter(void *){ - //dont do anything and assume the bastard committed it - //static_cast(obj)->commit(0); - } - void *get_buff(void) const{return _curr_buff.buff->cast() + _curr_buff.offset;} size_t get_size(void) const{return _curr_buff.buff->size() - _curr_buff.offset;} - bool _expired; offset_send_buffer _curr_buff, _next_buff; commit_cb_type _commit_cb; }; @@ -210,7 +199,7 @@ void usrp1_impl::io_impl::flush_send_buff(void){ bool usrp1_impl::io_impl::get_send_buffs( vrt_packet_handler::managed_send_buffs_t &buffs ){ - UHD_ASSERT_THROW(omsb.expired() and buffs.size() == 1); + UHD_ASSERT_THROW(buffs.size() == 1); //try to get a new managed buffer with timeout offset_send_buffer next_buff(data_transport->get_send_buff(send_timeout)); -- cgit v1.2.3