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();
76 void *write_pointer();
81 void update_write_pointer(
int nitems);
83 void set_done(
bool done);
84 bool done()
const {
return d_done; }
89 block_sptr
link() {
return block_sptr(d_link); }
91 size_t nreaders()
const {
return d_readers.size(); }
105 void add_item_tag(
const tag_t &tag);
119 void remove_item_tag(
const tag_t &tag,
long id);
126 void prune_tags(uint64_t max_time);
128 std::multimap<uint64_t,tag_t>::iterator
get_tags_begin() {
return d_item_tags.begin(); }
129 std::multimap<uint64_t,tag_t>::iterator
get_tags_end() {
return d_item_tags.end(); }
130 std::multimap<uint64_t,tag_t>::iterator
get_tags_lower_bound(uint64_t x) {
return d_item_tags.lower_bound(x); }
131 std::multimap<uint64_t,tag_t>::iterator
get_tags_upper_bound(uint64_t x) {
return d_item_tags.upper_bound(x); }
139 (buffer_sptr buf,
int nzero_preload, block_sptr link,
int delay);
149 gr::vmcircbuf *d_vmcircbuf;
150 size_t d_sizeof_item;
151 std::vector<buffer_reader *> d_readers;
152 boost::weak_ptr<block> d_link;
159 unsigned int d_write_index;
160 uint64_t d_abs_write_offset;
162 std::multimap<uint64_t,tag_t> d_item_tags;
163 uint64_t d_last_min_items_read;
165 unsigned index_add(
unsigned a,
unsigned b)
172 assert(s < d_bufsize);
176 unsigned index_sub(
unsigned a,
unsigned b)
183 assert((
unsigned) s < d_bufsize);
187 virtual bool allocate_buffer(
int nitems,
size_t sizeof_item);
202 buffer(
int nitems,
size_t sizeof_item, block_sptr link);
207 void drop_reader(buffer_reader *reader);
218 buffer_add_reader(buffer_sptr buf,
int nzero_preload, block_sptr link=block_sptr(),
int delay=0);
242 void declare_sample_delay(
unsigned delay);
249 unsigned sample_delay()
const;
254 int items_available()
const;
259 buffer_sptr
buffer()
const {
return d_buffer; }
272 const void *read_pointer();
277 void update_read_pointer(
int nitems);
279 void set_done(
bool done) { d_buffer->set_done(done); }
280 bool done()
const {
return d_buffer->done(); }
292 block_sptr
link() {
return block_sptr(d_link); }
307 void get_tags_in_range(std::vector<tag_t> &
v,
317 buffer_add_reader(buffer_sptr buf,
int nzero_preload, block_sptr link,
int delay);
319 buffer_sptr d_buffer;
320 unsigned int d_read_index;
321 uint64_t d_abs_read_offset;
322 boost::weak_ptr<block> d_link;
323 unsigned d_attr_delay;
buffer_sptr buffer() const
Return buffer this reader reads from.
Definition: buffer.h:259
How we keep track of the readers of a gr::buffer.
Definition: buffer.h:230
unsigned d_max_reader_delay
Definition: buffer.h:146
void set_done(bool done)
Definition: buffer.h:279
char * d_base
Definition: buffer.h:142
uint64_t nitems_read()
Definition: buffer.h:284
gr::thread::mutex * mutex()
Definition: buffer.h:94
std::multimap< uint64_t, tag_t >::iterator get_tags_lower_bound(uint64_t x)
Definition: buffer.h:130
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:265
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.
Definition: cc_common.h:45
#define GR_RUNTIME_API
Definition: gnuradio-runtime/include/gnuradio/api.h:30
bool done() const
Definition: buffer.h:280
Single writer, multiple reader fifo.
Definition: buffer.h:55
block_sptr link()
Return the block that reads via this reader.
Definition: buffer.h:292
size_t get_sizeof_item()
Definition: buffer.h:98
size_t get_sizeof_item()
Definition: buffer.h:286
std::multimap< uint64_t, tag_t >::iterator get_tags_end()
Definition: buffer.h:129
gr::thread::mutex * mutex()
Definition: buffer.h:282
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:89
buffer_reader * reader(size_t index)
Definition: buffer.h:92
size_t nreaders() const
Definition: buffer.h:91
uint64_t nitems_written()
Definition: buffer.h:96
std::multimap< uint64_t, tag_t >::iterator get_tags_upper_bound(uint64_t x)
Definition: buffer.h:131
std::multimap< uint64_t, tag_t >::iterator get_tags_begin()
Definition: buffer.h:128
boost::mutex mutex
Definition: thread.h:46
bool done() const
Definition: buffer.h:84
int bufsize() const
return size of this buffer in items
Definition: buffer.h:68
unsigned int d_bufsize
Definition: buffer.h:143
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