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; }
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);
129 std::deque<tag_t>::iterator
get_tags_end() {
return d_item_tags.end(); }
147 gr::vmcircbuf *d_vmcircbuf;
148 size_t d_sizeof_item;
149 std::vector<buffer_reader *> d_readers;
150 boost::weak_ptr<block> d_link;
157 unsigned int d_write_index;
160 std::deque<tag_t> d_item_tags;
163 unsigned index_add(
unsigned a,
unsigned b)
170 assert(s < d_bufsize);
174 unsigned index_sub(
unsigned a,
unsigned b)
181 assert((
unsigned) s < d_bufsize);
185 virtual bool allocate_buffer(
int nitems,
size_t sizeof_item);
200 buffer(
int nitems,
size_t sizeof_item, block_sptr link);
205 void drop_reader(buffer_reader *reader);
216 buffer_add_reader(buffer_sptr buf,
int nzero_preload, block_sptr link=block_sptr(),
int delay=0);
240 void declare_sample_delay(
unsigned delay);
247 unsigned sample_delay()
const;
252 int items_available()
const;
270 const void *read_pointer();
275 void update_read_pointer(
int nitems);
277 void set_done(
bool done) { d_buffer->set_done(done); }
278 bool done()
const {
return d_buffer->done(); }
305 void get_tags_in_range(std::vector<tag_t> &v,
318 unsigned int d_read_index;
320 boost::weak_ptr<block> d_link;
321 unsigned d_attr_delay;
buffer_sptr buffer() const
Return buffer this reader reads from.
Definition: buffer.h:257
How we keep track of the readers of a gr::buffer.
Definition: buffer.h:228
unsigned d_max_reader_delay
Definition: buffer.h:144
void set_done(bool done)
Definition: buffer.h:277
char * d_base
Definition: buffer.h:140
uint64_t nitems_read()
Definition: buffer.h:282
gr::thread::mutex * mutex()
Definition: buffer.h:94
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:263
std::deque< tag_t >::iterator get_tags_end()
Definition: buffer.h:129
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.
std::deque< tag_t >::iterator get_tags_begin()
Definition: buffer.h:128
#define GR_RUNTIME_API
Definition: gnuradio-runtime/include/gnuradio/api.h:30
shared_ptr documentation stub
Definition: shared_ptr_docstub.h:15
bool done() const
Definition: buffer.h:278
Single writer, multiple reader fifo.
Definition: buffer.h:55
block_sptr link()
Return the block that reads via this reader.
Definition: buffer.h:290
size_t get_sizeof_item()
Definition: buffer.h:98
size_t get_sizeof_item()
Definition: buffer.h:284
unsigned __int64 uint64_t
Definition: stdint.h:90
gr::thread::mutex * mutex()
Definition: buffer.h:280
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
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:141
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