diff options
author | Josh Blum <josh@joshknows.com> | 2011-02-07 12:32:12 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-02-07 12:32:12 -0800 |
commit | ef351624eeb898e17662000a40b50076133118c7 (patch) | |
tree | 841cc50addc98183bf4b6a35dbe2b5375d08cc6c /host/lib/transport | |
parent | fec5fc2d319ab2808f88d2f4cec734a8102f18ca (diff) | |
download | uhd-ef351624eeb898e17662000a40b50076133118c7.tar.gz uhd-ef351624eeb898e17662000a40b50076133118c7.tar.bz2 uhd-ef351624eeb898e17662000a40b50076133118c7.zip |
uhd: replace asio buffer in make safe w/ memory and length, makes things simpler
Diffstat (limited to 'host/lib/transport')
-rw-r--r-- | host/lib/transport/libusb1_zero_copy.cpp | 4 | ||||
-rw-r--r-- | host/lib/transport/udp_zero_copy_asio.cpp | 15 | ||||
-rw-r--r-- | host/lib/transport/zero_copy.cpp | 40 |
3 files changed, 33 insertions, 26 deletions
diff --git a/host/lib/transport/libusb1_zero_copy.cpp b/host/lib/transport/libusb1_zero_copy.cpp index 5ae6db39e..ca37f351f 100644 --- a/host/lib/transport/libusb1_zero_copy.cpp +++ b/host/lib/transport/libusb1_zero_copy.cpp @@ -398,7 +398,7 @@ managed_recv_buffer::sptr libusb_zero_copy_impl::get_recv_buff(double timeout){ } else { return managed_recv_buffer::make_safe( - boost::asio::const_buffer(lut->buffer, lut->actual_length), + lut->buffer, lut->actual_length, boost::bind(&libusb_zero_copy_impl::release, this, lut) ); } @@ -418,7 +418,7 @@ managed_send_buffer::sptr libusb_zero_copy_impl::get_send_buff(double timeout){ } else { return managed_send_buffer::make_safe( - boost::asio::mutable_buffer(lut->buffer, this->get_send_frame_size()), + lut->buffer, this->get_send_frame_size(), boost::bind(&libusb_zero_copy_impl::commit, this, lut, _1) ); } diff --git a/host/lib/transport/udp_zero_copy_asio.cpp b/host/lib/transport/udp_zero_copy_asio.cpp index 0f16e7d14..90cd2a9ce 100644 --- a/host/lib/transport/udp_zero_copy_asio.cpp +++ b/host/lib/transport/udp_zero_copy_asio.cpp @@ -149,7 +149,8 @@ public: asio::mutable_buffer buff; if (_pending_recv_buffs.pop_with_timed_wait(buff, timeout)){ return managed_recv_buffer::make_safe( - buff, boost::bind( + asio::buffer_cast<const void *>(buff), + asio::buffer_size(buff), boost::bind( &udp_zero_copy_asio_impl::release, this, asio::buffer_cast<void*>(buff) ) @@ -193,10 +194,8 @@ public: and _pending_recv_buffs.pop_with_haste(buff) ){ return managed_recv_buffer::make_safe( - asio::buffer( - boost::asio::buffer_cast<void *>(buff), - _socket->receive(asio::buffer(buff)) - ), + boost::asio::buffer_cast<void *>(buff), + _socket->receive(asio::buffer(buff)), boost::bind( &udp_zero_copy_asio_impl::release, this, asio::buffer_cast<void*>(buff) @@ -231,7 +230,8 @@ public: asio::mutable_buffer buff; if (_pending_send_buffs.pop_with_timed_wait(buff, timeout)){ return managed_send_buffer::make_safe( - buff, boost::bind( + asio::buffer_cast<void *>(buff), + asio::buffer_size(buff), boost::bind( &udp_zero_copy_asio_impl::commit, this, asio::buffer_cast<void*>(buff), _1 ) @@ -258,7 +258,8 @@ public: asio::mutable_buffer buff; if (_pending_send_buffs.pop_with_haste(buff)){ return managed_send_buffer::make_safe( - buff, boost::bind( + asio::buffer_cast<void *>(buff), + asio::buffer_size(buff), boost::bind( &udp_zero_copy_asio_impl::commit, this, asio::buffer_cast<void*>(buff), _1 ) diff --git a/host/lib/transport/zero_copy.cpp b/host/lib/transport/zero_copy.cpp index a5a864a04..b91eaae1d 100644 --- a/host/lib/transport/zero_copy.cpp +++ b/host/lib/transport/zero_copy.cpp @@ -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 @@ -29,10 +29,9 @@ static void release_nop(void){ class safe_managed_receive_buffer : public managed_recv_buffer{ public: safe_managed_receive_buffer( - const boost::asio::const_buffer &buff, - const release_fcn_t &release_fcn + const void *buff, size_t size, const release_fcn_t &release_fcn ): - _buff(buff), _release_fcn(release_fcn) + _buff(buff), _size(size), _release_fcn(release_fcn) { /* NOP */ } @@ -48,19 +47,23 @@ public: } private: - const boost::asio::const_buffer &get(void) const{ + const void *get_buff(void) const{ return _buff; } - const boost::asio::const_buffer _buff; + size_t get_size(void) const{ + return _size; + } + + const void *_buff; + size_t _size; release_fcn_t _release_fcn; }; managed_recv_buffer::sptr managed_recv_buffer::make_safe( - const boost::asio::const_buffer &buff, - const release_fcn_t &release_fcn + const void *buff, size_t size, const release_fcn_t &release_fcn ){ - return sptr(new safe_managed_receive_buffer(buff, release_fcn)); + return sptr(new safe_managed_receive_buffer(buff, size, release_fcn)); } /*********************************************************************** @@ -73,10 +76,9 @@ static void commit_nop(size_t){ class safe_managed_send_buffer : public managed_send_buffer{ public: safe_managed_send_buffer( - const boost::asio::mutable_buffer &buff, - const commit_fcn_t &commit_fcn + void *buff, size_t size, const commit_fcn_t &commit_fcn ): - _buff(buff), _commit_fcn(commit_fcn) + _buff(buff), _size(size), _commit_fcn(commit_fcn) { /* NOP */ } @@ -92,17 +94,21 @@ public: } private: - const boost::asio::mutable_buffer &get(void) const{ + void *get_buff(void) const{ return _buff; } - const boost::asio::mutable_buffer _buff; + size_t get_size(void) const{ + return _size; + } + + void *_buff; + size_t _size; commit_fcn_t _commit_fcn; }; safe_managed_send_buffer::sptr managed_send_buffer::make_safe( - const boost::asio::mutable_buffer &buff, - const commit_fcn_t &commit_fcn + void *buff, size_t size, const commit_fcn_t &commit_fcn ){ - return sptr(new safe_managed_send_buffer(buff, commit_fcn)); + return sptr(new safe_managed_send_buffer(buff, size, commit_fcn)); } |