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(); }
110 void add_item_tag(
const tag_t &tag);
124 void remove_item_tag(
const tag_t &tag,
long id);
131 void prune_tags(uint64_t max_time);
133 std::multimap<uint64_t,tag_t>::iterator
get_tags_begin() {
return d_item_tags.begin(); }
134 std::multimap<uint64_t,tag_t>::iterator
get_tags_end() {
return d_item_tags.end(); }
135 std::multimap<uint64_t,tag_t>::iterator
get_tags_lower_bound(uint64_t x) {
return d_item_tags.lower_bound(x); }
136 std::multimap<uint64_t,tag_t>::iterator
get_tags_upper_bound(uint64_t x) {
return d_item_tags.upper_bound(x); }
144 (buffer_sptr buf,
int nzero_preload, block_sptr link,
int delay);
154 gr::vmcircbuf *d_vmcircbuf;
155 size_t d_sizeof_item;
156 std::vector<buffer_reader *> d_readers;
157 boost::weak_ptr<block> d_link;
164 unsigned int d_write_index;
165 uint64_t d_abs_write_offset;
167 std::multimap<uint64_t,tag_t> d_item_tags;
168 uint64_t d_last_min_items_read;
170 unsigned index_add(
unsigned a,
unsigned b)
177 assert(s < d_bufsize);
181 unsigned index_sub(
unsigned a,
unsigned b)
188 assert((
unsigned) s < d_bufsize);
192 virtual bool allocate_buffer(
int nitems,
size_t sizeof_item);
207 buffer(
int nitems,
size_t sizeof_item, block_sptr link);
212 void drop_reader(buffer_reader *reader);
223 buffer_add_reader(buffer_sptr buf,
int nzero_preload, block_sptr link=block_sptr(),
int delay=0);
247 void declare_sample_delay(
unsigned delay);
254 unsigned sample_delay()
const;
259 int items_available()
const;
264 buffer_sptr
buffer()
const {
return d_buffer; }
277 const void *read_pointer();
282 void update_read_pointer(
int nitems);
284 void set_done(
bool done) { d_buffer->set_done(done); }
285 bool done()
const {
return d_buffer->done(); }
297 block_sptr
link() {
return block_sptr(d_link); }
312 void get_tags_in_range(std::vector<tag_t> &
v,
322 buffer_add_reader(buffer_sptr buf,
int nzero_preload, block_sptr link,
int delay);
324 buffer_sptr d_buffer;
325 unsigned int d_read_index;
326 uint64_t d_abs_read_offset;
327 boost::weak_ptr<block> d_link;
328 unsigned d_attr_delay;
buffer_sptr buffer() const
Return buffer this reader reads from.
Definition: buffer.h:264
How we keep track of the readers of a gr::buffer.
Definition: buffer.h:235
const char * base() const
return the base address of the buffer
Definition: buffer.h:73
unsigned d_max_reader_delay
Definition: buffer.h:151
void set_done(bool done)
Definition: buffer.h:284
char * d_base
Definition: buffer.h:147
uint64_t nitems_read()
Definition: buffer.h:289
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:135
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:270
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:285
Single writer, multiple reader fifo.
Definition: buffer.h:55
Include this header to use the message passing features.
Definition: logger.h:131
block_sptr link()
Return the block that reads via this reader.
Definition: buffer.h:297
size_t get_sizeof_item()
Definition: buffer.h:103
size_t get_sizeof_item()
Definition: buffer.h:291
std::multimap< uint64_t, tag_t >::iterator get_tags_end()
Definition: buffer.h:134
gr::thread::mutex * mutex()
Definition: buffer.h:287
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:136
std::multimap< uint64_t, tag_t >::iterator get_tags_begin()
Definition: buffer.h:133
boost::mutex mutex
Definition: thread.h:46
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:148
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