USRP Hardware Driver and Device Manual Version: 4.10.0.0_release
UHD and USRP Manual
 
Loading...
Searching...
No Matches
buffer_pool.hpp
Go to the documentation of this file.
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>
12#include <cstddef>
13#include <memory>
14#include <vector>
15
16namespace uhd { namespace transport {
17
22class UHD_API buffer_pool : uhd::noncopyable
23{
24public:
25 typedef std::shared_ptr<buffer_pool> sptr;
26 typedef void* ptr_type;
27
28 ~buffer_pool() = default;
29
37 static sptr make(
38 const size_t num_buffs, const size_t buff_size, const size_t alignment = 16);
39
41 ptr_type at(const size_t index) const
42 {
43 return _ptrs.at(index);
44 }
45
47 size_t size() const
48 {
49 return _ptrs.size();
50 }
51
52private:
53 buffer_pool(std::vector<ptr_type>&& ptrs, std::unique_ptr<char[]> mem)
54 : _ptrs(std::move(ptrs)), _mem(std::move(mem))
55 {
56 }
57
58 std::vector<ptr_type> _ptrs;
59 std::unique_ptr<char[]> _mem;
60};
61
62}} // namespace uhd::transport
Definition buffer_pool.hpp:23
static sptr make(const size_t num_buffs, const size_t buff_size, const size_t alignment=16)
ptr_type at(const size_t index) const
Get a pointer to the buffer start at the specified index.
Definition buffer_pool.hpp:41
std::shared_ptr< buffer_pool > sptr
Definition buffer_pool.hpp:25
size_t size() const
Get the number of buffers in this pool.
Definition buffer_pool.hpp:47
void * ptr_type
Definition buffer_pool.hpp:26
#define UHD_API
Definition config.h:87
STL namespace.
Definition adapter_id.hpp:11
Definition build_info.hpp:12
boost::noncopyable noncopyable
Definition noncopyable.hpp:45