1 //
2 // Copyright 2011,2014 Ettus Research LLC
3 // Copyright 2018 Ettus Research, a National Instruments Company
4 //
5 // SPDX-License-Identifier: GPL-3.0-or-later
6 //
7 
8 #pragma once
9 
10 #include <uhd/config.hpp>
11 #include <uhd/utils/noncopyable.hpp>
12 #include <memory>
13 
14 namespace uhd { namespace transport {
15 
16 /*!
17  * A buffer pool manages memory for a homogeneous set of buffers.
18  * Each buffer is the pool start at a 16-byte alignment boundary.
19  */
20 class UHD_API buffer_pool : uhd::noncopyable
21 {
22 public:
23     typedef std::shared_ptr<buffer_pool> sptr;
24     typedef void* ptr_type;
25 
26     virtual ~buffer_pool(void) = 0;
27 
28     /*!
29      * Make a new buffer pool.
30      * \param num_buffs the number of buffers to allocate
31      * \param buff_size the size of each buffer in bytes
32      * \param alignment the alignment boundary in bytes
33      * \return a new buffer pool buff_size X num_buffs
34      */
35     static sptr make(
36         const size_t num_buffs, const size_t buff_size, const size_t alignment = 16);
37 
38     //! Get a pointer to the buffer start at the specified index
39     virtual ptr_type at(const size_t index) const = 0;
40 
41     //! Get the number of buffers in this pool
42     virtual size_t size(void) const = 0;
43 };
44 
45 }} // namespace uhd::transport
46 
47