diff options
author | Josh Blum <josh@joshknows.com> | 2011-01-03 01:43:48 -0800 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-01-03 01:43:48 -0800 |
commit | ed6a2941f8e144e5f02a7a34c9d4764c65174617 (patch) | |
tree | cd3392968971ac7ee28832f6ed7140a216497b59 /host/include | |
parent | 2d1f96d834baf7cb92305e9ecdadbe0ad13a8d04 (diff) | |
download | uhd-ed6a2941f8e144e5f02a7a34c9d4764c65174617.tar.gz uhd-ed6a2941f8e144e5f02a7a34c9d4764c65174617.tar.bz2 uhd-ed6a2941f8e144e5f02a7a34c9d4764c65174617.zip |
uhd: created buffer pool to allocate aligned memory, and implemented in transports
Diffstat (limited to 'host/include')
-rw-r--r-- | host/include/uhd/transport/CMakeLists.txt | 1 | ||||
-rw-r--r-- | host/include/uhd/transport/buffer_pool.hpp | 59 | ||||
-rw-r--r-- | host/include/uhd/transport/if_addrs.hpp | 6 |
3 files changed, 63 insertions, 3 deletions
diff --git a/host/include/uhd/transport/CMakeLists.txt b/host/include/uhd/transport/CMakeLists.txt index 2c84c0724..adcfc7598 100644 --- a/host/include/uhd/transport/CMakeLists.txt +++ b/host/include/uhd/transport/CMakeLists.txt @@ -21,6 +21,7 @@ INSTALL(FILES alignment_buffer.ipp bounded_buffer.hpp bounded_buffer.ipp + buffer_pool.hpp convert_types.hpp convert_types.ipp if_addrs.hpp diff --git a/host/include/uhd/transport/buffer_pool.hpp b/host/include/uhd/transport/buffer_pool.hpp new file mode 100644 index 000000000..b6c683948 --- /dev/null +++ b/host/include/uhd/transport/buffer_pool.hpp @@ -0,0 +1,59 @@ +// +// Copyright 2010 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 +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// + +#ifndef INCLUDED_UHD_TRANSPORT_BUFFER_POOL_HPP +#define INCLUDED_UHD_TRANSPORT_BUFFER_POOL_HPP + +#include <uhd/config.hpp> +#include <boost/utility.hpp> +#include <boost/shared_ptr.hpp> + +namespace uhd{ namespace transport{ + + /*! + * A buffer pool manages memory for a homogeneous set of buffers. + * Each buffer is the pool start at a 16-byte alignment boundary. + */ + class UHD_API buffer_pool : boost::noncopyable{ + public: + typedef boost::shared_ptr<buffer_pool> sptr; + typedef void * ptr_type; + + /*! + * Make a new buffer pool. + * \param num_buffs the number of buffers to allocate + * \param buff_size the size of each buffer in bytes + * \param alignment the alignment boundary in bytes + * \return a new buffer pool buff_size X num_buffs + */ + static sptr make( + const size_t num_buffs, + const size_t buff_size, + const size_t alignment = 16 + ); + + //! Get a pointer to the buffer start at the specified index + virtual ptr_type at(const size_t index) const = 0; + + //! Get the number of buffers in this pool + virtual size_t size(void) const = 0; + }; + +}} //namespace + + +#endif /* INCLUDED_UHD_TRANSPORT_BUFFER_POOL_HPP */ diff --git a/host/include/uhd/transport/if_addrs.hpp b/host/include/uhd/transport/if_addrs.hpp index fbbb35e1d..84f24cb5a 100644 --- a/host/include/uhd/transport/if_addrs.hpp +++ b/host/include/uhd/transport/if_addrs.hpp @@ -15,8 +15,8 @@ // along with this program. If not, see <http://www.gnu.org/licenses/>. // -#ifndef INCLUDED_UHD_IFADDRS_HPP -#define INCLUDED_UHD_IFADDRS_HPP +#ifndef INCLUDED_UHD_TRANSPORT_IF_ADDRS_HPP +#define INCLUDED_UHD_TRANSPORT_IF_ADDRS_HPP #include <uhd/config.hpp> #include <string> @@ -44,4 +44,4 @@ namespace uhd{ namespace transport{ }} //namespace -#endif /* INCLUDED_UHD_IFADDRS_HPP */ +#endif /* INCLUDED_UHD_TRANSPORT_IF_ADDRS_HPP */ |