23 #ifndef INCLUDED_GR_RUNTIME_BUFFER_H 24 #define INCLUDED_GR_RUNTIME_BUFFER_H 29 #include <boost/weak_ptr.hpp> 49 block_sptr link=block_sptr());
63 int space_available();
73 const char*
base()
const {
return static_cast<const char*
>(d_base); }
81 void *write_pointer();
86 void update_write_pointer(
int nitems);
88 void set_done(
bool done);
89 bool done()
const {
return d_done; }
94 block_sptr
link() {
return block_sptr(d_link); }
96 size_t nreaders()
const {
return d_readers.size(); }
112 void add_item_tag(
const tag_t &tag);
126 void remove_item_tag(
const tag_t &tag,
long id);
133 void prune_tags(uint64_t max_time);
135 std::multimap<uint64_t,tag_t>::iterator
get_tags_begin() {
return d_item_tags.begin(); }
136 std::multimap<uint64_t,tag_t>::iterator
get_tags_end() {
return d_item_tags.end(); }
137 std::multimap<uint64_t,tag_t>::iterator
get_tags_lower_bound(uint64_t x) {
return d_item_tags.lower_bound(x); }
138 std::multimap<uint64_t,tag_t>::iterator
get_tags_upper_bound(uint64_t x) {
return d_item_tags.upper_bound(x); }
146 (buffer_sptr buf,
int nzero_preload, block_sptr link,
int delay);
156 gr::vmcircbuf *d_vmcircbuf;
157 size_t d_sizeof_item;
158 std::vector<buffer_reader *> d_readers;
159 boost::weak_ptr<block> d_link;
166 unsigned int d_write_index;
167 uint64_t d_abs_write_offset;
169 std::multimap<uint64_t,tag_t> d_item_tags;
170 uint64_t d_last_min_items_read;
172 unsigned index_add(
unsigned a,
unsigned b)
179 assert(s < d_bufsize);
183 unsigned index_sub(
unsigned a,
unsigned b)
190 assert((
unsigned) s < d_bufsize);
194 virtual bool allocate_buffer(
int nitems,
size_t sizeof_item);
209 buffer(
int nitems,
size_t sizeof_item, block_sptr link);
225 buffer_add_reader(buffer_sptr buf,
int nzero_preload, block_sptr link=block_sptr(),
int delay=0);
249 void declare_sample_delay(
unsigned delay);
256 unsigned sample_delay()
const;
261 int items_available()
const;
266 buffer_sptr
buffer()
const {
return d_buffer; }
279 const void *read_pointer();
284 void update_read_pointer(
int nitems);
286 void set_done(
bool done) { d_buffer->set_done(done); }
287 bool done()
const {
return d_buffer->done(); }
301 block_sptr
link() {
return block_sptr(d_link); }
316 void get_tags_in_range(std::vector<tag_t> &
v,
326 buffer_add_reader(buffer_sptr buf,
int nzero_preload, block_sptr link,
int delay);
328 buffer_sptr d_buffer;
329 unsigned int d_read_index;
330 uint64_t d_abs_read_offset;
331 boost::weak_ptr<block> d_link;
332 unsigned d_attr_delay;
buffer_sptr buffer() const
Return buffer this reader reads from.
Definition: buffer.h:266
How we keep track of the readers of a gr::buffer.
Definition: buffer.h:237
const char * base() const
return the base address of the buffer
Definition: buffer.h:73
unsigned d_max_reader_delay
Definition: buffer.h:153
void set_done(bool done)
Definition: buffer.h:286
char * d_base
Definition: buffer.h:149
uint64_t nitems_read()
Definition: buffer.h:291
void reset_nitem_counter()
Definition: buffer.h:293
gr::thread::mutex * mutex()
Definition: buffer.h:99
std::multimap< uint64_t, tag_t >::iterator get_tags_lower_bound(uint64_t x)
Definition: buffer.h:137
int max_possible_items_available() const
Return maximum number of items that could ever be available for reading. This is used as a sanity che...
Definition: buffer.h:272
GR_RUNTIME_API buffer_reader_sptr buffer_add_reader(buffer_sptr buf, int nzero_preload, block_sptr link=block_sptr(), int delay=0)
Create a new gr::buffer_reader and attach it to buffer buf.
void reset_nitem_counter()
Definition: buffer.h:103
Definition: cc_common.h:45
#define GR_RUNTIME_API
Definition: gnuradio-runtime/include/gnuradio/api.h:30
bool done() const
Definition: buffer.h:287
Single writer, multiple reader fifo.
Definition: buffer.h:55
Include this header to use the message passing features.
Definition: logger.h:695
block_sptr link()
Return the block that reads via this reader.
Definition: buffer.h:301
size_t get_sizeof_item()
Definition: buffer.h:105
size_t get_sizeof_item()
Definition: buffer.h:295
std::multimap< uint64_t, tag_t >::iterator get_tags_end()
Definition: buffer.h:136
gr::thread::mutex * mutex()
Definition: buffer.h:289
GR_RUNTIME_API long buffer_ncurrently_allocated()
returns # of buffers currently allocated
block_sptr link()
Return the block that writes to this buffer.
Definition: buffer.h:94
buffer_reader * reader(size_t index)
Definition: buffer.h:97
size_t nreaders() const
Definition: buffer.h:96
uint64_t nitems_written()
Definition: buffer.h:101
std::multimap< uint64_t, tag_t >::iterator get_tags_upper_bound(uint64_t x)
Definition: buffer.h:138
std::multimap< uint64_t, tag_t >::iterator get_tags_begin()
Definition: buffer.h:135
boost::mutex mutex
Definition: thread.h:48
bool done() const
Definition: buffer.h:89
int bufsize() const
return size of this buffer in items
Definition: buffer.h:68
unsigned int d_bufsize
Definition: buffer.h:150
GR_RUNTIME_API buffer_sptr make_buffer(int nitems, size_t sizeof_item, block_sptr link=block_sptr())
Allocate a buffer that holds at least nitems of size sizeof_item.
GR_RUNTIME_API long buffer_reader_ncurrently_allocated()
returns # of buffer_readers currently allocated