GNU Radio C++ API Reference: buffer_double_mapped.h Source File

| GNU Radio C++ API Reference 3.10.12.0 The Free & Open Software Radio Ecosystem |

Loading...
Searching...
No Matches
buffer_double_mapped.h
Go to the documentation of this file.
1/* -*- c++ -*- */
2/*
3 * Copyright 2020 Free Software Foundation, Inc.
4 *
5 * This file is part of GNU Radio
6 *
7 * SPDX-License-Identifier: GPL-3.0-or-later
8 *
9 */
10
11#ifndef INCLUDED_GR_RUNTIME_BUFFER_DOUBLE_MAPPED_H
12#define INCLUDED_GR_RUNTIME_BUFFER_DOUBLE_MAPPED_H
13
14#include <gnuradio/api.h>
15#include <gnuradio/buffer.h>
16#include <gnuradio/buffer_type.h>
17#include <gnuradio/logger.h>
18#include <gnuradio/runtime_types.h>
19
20namespace gr {
21
22class vmcircbuf;
23
24/*!
25 * \brief Single writer, multiple reader fifo.
26 * \ingroup internal
27 */
28 class GR_RUNTIME_API buffer_double_mapped : public buffer
29{
30public:
31 static buffer_type type;
32
33 static buffer_sptr make_buffer(int nitems,
34 size_t sizeof_item,
35 uint64_t downstream_lcm_nitems,
36 uint32_t downstream_max_out_mult,
37 block_sptr link = block_sptr(),
38 block_sptr buf_owner = block_sptr());
39
40 gr::logger_ptr d_logger;
41 gr::logger_ptr d_debug_logger;
42
43 ~buffer_double_mapped() override;
44
45 /*!
46 * \brief return number of items worth of space available for writing
47 */
48 int space_available() override;
49
50 /*!
51 * Inherited from buffer class.
52 * @param nitems is the number of items produced by the general_work() function.
53 */
54 void post_work([[maybe_unused]] int nitems) override {}
55
56protected:
57 /*!
58 * sets d_vmcircbuf, d_base, d_bufsize.
59 * returns true iff successful.
60 */
61 bool allocate_buffer(int nitems) override;
62
63 unsigned index_add(unsigned a, unsigned b) override
64 {
65 unsigned s = a + b;
66
67 if (s >= d_bufsize)
68 s -= d_bufsize;
69
70 assert(s < d_bufsize);
71 return s;
72 }
73
74 unsigned index_sub(unsigned a, unsigned b) override
75 {
76 int s = a - b;
77
78 if (s < 0)
79 s += d_bufsize;
80
81 assert((unsigned)s < d_bufsize);
82 return s;
83 }
84
85private:
86 friend class buffer_reader;
87
88 friend GR_RUNTIME_API buffer_sptr make_buffer(int nitems,
89 size_t sizeof_item,
90 uint64_t downstream_lcm_nitems,
91 block_sptr link,
92 block_sptr buf_owner);
93 friend GR_RUNTIME_API buffer_sptr
94 make_buffer_double_mapped(int nitems,
95 size_t sizeof_item,
96 uint64_t downstream_lcm_nitems,
97 uint32_t downstream_max_out_mult,
98 block_sptr link,
99 block_sptr buf_owner);
100
101 std::unique_ptr<gr::vmcircbuf> d_vmcircbuf;
102
103 /*!
104 * \brief constructor is private. Use gr_make_buffer to create instances.
105 *
106 * Allocate a buffer that holds at least \p nitems of size \p sizeof_item.
107 *
108 * \param nitems is the minimum number of items the buffer will hold.
109 * \param sizeof_item is the size of an item in bytes.
110 * \param downstream_lcm_nitems is the least common multiple of the items to
111 * read by downstream blocks
112 * \param downstream_max_out_mult is the maximum output multiple of all
113 * downstream blocks
114 * \param link is the block that writes to this buffer.
115 *
116 * The total size of the buffer will be rounded up to a system
117 * dependent boundary. This is typically the system page size, but
118 * under MS windows is 64KB.
119 */
120 buffer_double_mapped(int nitems,
121 size_t sizeof_item,
122 uint64_t downstream_lcm_nitems,
123 uint32_t downstream_max_out_mult,
124 block_sptr link);
125};
126
127} /* namespace gr */
128
129
130#endif /* INCLUDED_GR_RUNTIME_BUFFER_DOUBLE_MAPPED_H */
buffer.h
buffer_type.h
gr::buffer_double_mapped::index_sub
unsigned index_sub(unsigned a, unsigned b) override
Decrement read or write index for this buffer.
Definition buffer_double_mapped.h:74
gr::buffer_double_mapped::index_add
unsigned index_add(unsigned a, unsigned b) override
Increment read or write index for this buffer.
Definition buffer_double_mapped.h:63
gr::buffer_double_mapped::make_buffer
friend GR_RUNTIME_API buffer_sptr make_buffer(int nitems, size_t sizeof_item, uint64_t downstream_lcm_nitems, block_sptr link, block_sptr buf_owner)
gr::buffer_double_mapped::make_buffer_double_mapped
friend GR_RUNTIME_API buffer_sptr make_buffer_double_mapped(int nitems, size_t sizeof_item, uint64_t downstream_lcm_nitems, uint32_t downstream_max_out_mult, block_sptr link, block_sptr buf_owner)
gr::buffer_double_mapped::~buffer_double_mapped
~buffer_double_mapped() override
gr::buffer_double_mapped::allocate_buffer
bool allocate_buffer(int nitems) override
gr::buffer_double_mapped::d_debug_logger
gr::logger_ptr d_debug_logger
Definition buffer_double_mapped.h:41
gr::buffer_double_mapped::d_logger
gr::logger_ptr d_logger
Definition buffer_double_mapped.h:40
gr::buffer_double_mapped::buffer_reader
friend class buffer_reader
Definition buffer_double_mapped.h:86
gr::buffer_double_mapped::make_buffer
static buffer_sptr make_buffer(int nitems, size_t sizeof_item, uint64_t downstream_lcm_nitems, uint32_t downstream_max_out_mult, block_sptr link=block_sptr(), block_sptr buf_owner=block_sptr())
gr::buffer_double_mapped::type
static buffer_type type
Definition buffer_double_mapped.h:31
gr::buffer_double_mapped::space_available
int space_available() override
return number of items worth of space available for writing
gr::buffer_double_mapped::post_work
void post_work(int nitems) override
Definition buffer_double_mapped.h:54
gr::buffer::d_bufsize
unsigned int d_bufsize
Definition buffer.h:295
gr::buffer::link
block_sptr link()
Return the block that writes to this buffer.
Definition buffer.h:120
gr::buffer::buffer
buffer(buffer_mapping_type buftype, int nitems, size_t sizeof_item, uint64_t downstream_lcm_nitems, uint32_t downstream_max_out_mult, block_sptr link)
constructor is private. Use gr_make_buffer to create instances.
api.h
GR_RUNTIME_API
#define GR_RUNTIME_API
Definition gnuradio-runtime/include/gnuradio/api.h:18
logger.h
gr
GNU Radio logging wrapper.
Definition basic_block.h:29
gr::buffer_type
const buffer_type_base & buffer_type
Definition buffer_type.h:85
gr::logger_ptr
std::shared_ptr< logger > logger_ptr
Definition logger.h:250
runtime_types.h