23 #ifndef INCLUDED_GR_RUNTIME_BUFFER_H 24 #define INCLUDED_GR_RUNTIME_BUFFER_H 30 #include <boost/weak_ptr.hpp> 50 block_sptr link = block_sptr());
64 int space_available();
74 const char*
base()
const {
return static_cast<const char*
>(d_base); }
82 void* write_pointer();
87 void update_write_pointer(
int nitems);
89 void set_done(
bool done);
90 bool done()
const {
return d_done; }
95 block_sptr
link() {
return block_sptr(d_link); }
97 size_t nreaders()
const {
return d_readers.size(); }
113 void add_item_tag(
const tag_t& tag);
127 void remove_item_tag(
const tag_t& tag,
long id);
134 void prune_tags(uint64_t max_time);
138 return d_item_tags.begin();
140 std::multimap<uint64_t, tag_t>::iterator
get_tags_end() {
return d_item_tags.end(); }
143 return d_item_tags.lower_bound(x);
147 return d_item_tags.upper_bound(x);
170 gr::vmcircbuf* d_vmcircbuf;
171 size_t d_sizeof_item;
172 std::vector<buffer_reader*> d_readers;
173 boost::weak_ptr<block> d_link;
180 unsigned int d_write_index;
181 uint64_t d_abs_write_offset;
183 std::multimap<uint64_t, tag_t> d_item_tags;
184 uint64_t d_last_min_items_read;
186 unsigned index_add(
unsigned a,
unsigned b)
193 assert(s < d_bufsize);
197 unsigned index_sub(
unsigned a,
unsigned b)
204 assert((
unsigned)s < d_bufsize);
208 virtual bool allocate_buffer(
int nitems,
size_t sizeof_item);
223 buffer(
int nitems,
size_t sizeof_item, block_sptr link);
240 block_sptr link = block_sptr(),
265 void declare_sample_delay(
unsigned delay);
272 unsigned sample_delay()
const;
277 int items_available()
const;
282 buffer_sptr
buffer()
const {
return d_buffer; }
295 const void* read_pointer();
300 void update_read_pointer(
int nitems);
302 void set_done(
bool done) { d_buffer->set_done(done); }
303 bool done()
const {
return d_buffer->done(); }
317 block_sptr
link() {
return block_sptr(d_link); }
333 void get_tags_in_range(std::vector<tag_t>&
v,
347 buffer_sptr d_buffer;
348 unsigned int d_read_index;
349 uint64_t d_abs_read_offset;
350 boost::weak_ptr<block> d_link;
351 unsigned d_attr_delay;
How we keep track of the readers of a gr::buffer.
Definition: buffer.h:253
unsigned d_max_reader_delay
Definition: buffer.h:167
void set_done(bool done)
Definition: buffer.h:302
char * d_base
Definition: buffer.h:163
uint64_t nitems_read()
Definition: buffer.h:307
void reset_nitem_counter()
Definition: buffer.h:309
gr::thread::mutex * mutex()
Definition: buffer.h:100
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::multimap< uint64_t, tag_t >::iterator get_tags_end()
Definition: buffer.h:140
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:288
void reset_nitem_counter()
Definition: buffer.h:104
Definition: cc_common.h:45
#define GR_RUNTIME_API
Definition: gnuradio-runtime/include/gnuradio/api.h:30
std::multimap< uint64_t, tag_t >::iterator get_tags_upper_bound(uint64_t x)
Definition: buffer.h:145
buffer_sptr buffer() const
Return buffer this reader reads from.
Definition: buffer.h:282
std::multimap< uint64_t, tag_t >::iterator get_tags_lower_bound(uint64_t x)
Definition: buffer.h:141
Single writer, multiple reader fifo.
Definition: buffer.h:56
GNU Radio logging wrapper for log4cpp library (C++ port of log4j)
Definition: basic_block.h:43
size_t nreaders() const
Definition: buffer.h:97
block_sptr link()
Return the block that reads via this reader.
Definition: buffer.h:317
size_t get_sizeof_item()
Definition: buffer.h:106
size_t get_sizeof_item()
Definition: buffer.h:311
std::multimap< uint64_t, tag_t >::iterator get_tags_begin()
Definition: buffer.h:136
gr::thread::mutex * mutex()
Definition: buffer.h:305
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:95
buffer_reader * reader(size_t index)
Definition: buffer.h:98
int bufsize() const
return size of this buffer in items
Definition: buffer.h:69
uint64_t nitems_written()
Definition: buffer.h:102
const char * base() const
return the base address of the buffer
Definition: buffer.h:74
boost::mutex mutex
Definition: thread.h:48
bool done() const
Definition: buffer.h:90
bool done() const
Definition: buffer.h:303
unsigned int d_bufsize
Definition: buffer.h:164
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