From ef351624eeb898e17662000a40b50076133118c7 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Mon, 7 Feb 2011 12:32:12 -0800 Subject: uhd: replace asio buffer in make safe w/ memory and length, makes things simpler --- host/include/uhd/transport/zero_copy.hpp | 63 ++++++++++++++------------------ 1 file changed, 27 insertions(+), 36 deletions(-) (limited to 'host/include') diff --git a/host/include/uhd/transport/zero_copy.hpp b/host/include/uhd/transport/zero_copy.hpp index 7d8fb4b83..d5a536b27 100644 --- a/host/include/uhd/transport/zero_copy.hpp +++ b/host/include/uhd/transport/zero_copy.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 @@ -19,7 +19,6 @@ #define INCLUDED_UHD_TRANSPORT_ZERO_COPY_HPP #include -#include #include #include #include @@ -40,13 +39,13 @@ namespace uhd{ namespace transport{ * Make a safe managed receive buffer: * A safe managed buffer ensures that release is called once, * either by the user or automatically upon deconstruction. - * \param buff a reference to the constant buffer + * \param buff a pointer into read-only memory + * \param size the length of the buffer in bytes * \param release_fcn callback to release the memory * \return a new managed receive buffer */ static sptr 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 ); /*! @@ -56,29 +55,25 @@ namespace uhd{ namespace transport{ */ virtual void release(void) = 0; - /*! - * Get the size of the underlying buffer. - * \return the number of bytes - */ - inline size_t size(void) const{ - return boost::asio::buffer_size(this->get()); - } - /*! * Get a pointer to the underlying buffer. * \return a pointer into memory */ template inline T cast(void) const{ - return boost::asio::buffer_cast(this->get()); + return static_cast(this->get_buff()); } - private: /*! - * Get a reference to the internal const buffer. - * The buffer has a reference to memory and a size. - * \return a boost asio const buffer + * Get the size of the underlying buffer. + * \return the number of bytes */ - virtual const boost::asio::const_buffer &get(void) const = 0; + inline size_t size(void) const{ + return this->get_size(); + } + + private: + virtual const void *get_buff(void) const = 0; + virtual size_t get_size(void) const = 0; }; /*! @@ -96,13 +91,13 @@ namespace uhd{ namespace transport{ * A safe managed buffer ensures that commit is called once, * either by the user or automatically upon deconstruction. * In the later case, the deconstructor will call commit(0). - * \param buff a reference to the mutable buffer + * \param buff a pointer into writable memory + * \param size the length of the buffer in bytes * \param commit_fcn callback to commit the memory * \return a new managed send buffer */ static sptr 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 ); /*! @@ -113,29 +108,25 @@ namespace uhd{ namespace transport{ */ virtual void commit(size_t num_bytes) = 0; - /*! - * Get the size of the underlying buffer. - * \return the number of bytes - */ - inline size_t size(void) const{ - return boost::asio::buffer_size(this->get()); - } - /*! * Get a pointer to the underlying buffer. * \return a pointer into memory */ template inline T cast(void) const{ - return boost::asio::buffer_cast(this->get()); + return static_cast(this->get_buff()); } - private: /*! - * Get a reference to the internal mutable buffer. - * The buffer has a reference to memory and a size. - * \return a boost asio mutable buffer + * Get the size of the underlying buffer. + * \return the number of bytes */ - virtual const boost::asio::mutable_buffer &get(void) const = 0; + inline size_t size(void) const{ + return this->get_size(); + } + + private: + virtual void *get_buff(void) const = 0; + virtual size_t get_size(void) const = 0; }; /*! -- cgit v1.2.3