aboutsummaryrefslogtreecommitdiffstats
path: root/host/include/uhd/transport/zero_copy.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'host/include/uhd/transport/zero_copy.hpp')
-rw-r--r--host/include/uhd/transport/zero_copy.hpp85
1 files changed, 23 insertions, 62 deletions
diff --git a/host/include/uhd/transport/zero_copy.hpp b/host/include/uhd/transport/zero_copy.hpp
index 7d8fb4b83..092028d09 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,10 +19,8 @@
#define INCLUDED_UHD_TRANSPORT_ZERO_COPY_HPP
#include <uhd/config.hpp>
-#include <boost/asio/buffer.hpp>
#include <boost/utility.hpp>
#include <boost/shared_ptr.hpp>
-#include <boost/function.hpp>
namespace uhd{ namespace transport{
@@ -31,23 +29,9 @@ namespace uhd{ namespace transport{
* Contains a reference to transport-managed memory,
* and a method to release the memory after reading.
*/
- class UHD_API managed_recv_buffer : boost::noncopyable{
+ class UHD_API managed_recv_buffer{
public:
typedef boost::shared_ptr<managed_recv_buffer> sptr;
- typedef boost::function<void(void)> release_fcn_t;
-
- /*!
- * 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 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
- );
/*!
* Signal to the transport that we are done with the buffer.
@@ -57,28 +41,24 @@ 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 <class T> inline T cast(void) const{
- return boost::asio::buffer_cast<T>(this->get());
+ return static_cast<T>(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;
};
/*!
@@ -86,24 +66,9 @@ namespace uhd{ namespace transport{
* Contains a reference to transport-managed memory,
* and a method to commit the memory after writing.
*/
- class UHD_API managed_send_buffer : boost::noncopyable{
+ class UHD_API managed_send_buffer{
public:
typedef boost::shared_ptr<managed_send_buffer> sptr;
- typedef boost::function<void(size_t)> commit_fcn_t;
-
- /*!
- * Make a safe managed send buffer:
- * 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 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
- );
/*!
* Signal to the transport that we are done with the buffer.
@@ -114,28 +79,24 @@ 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 <class T> inline T cast(void) const{
- return boost::asio::buffer_cast<T>(this->get());
+ return static_cast<T>(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;
};
/*!