Single writer, multiple reader fifo. More...
#include <gnuradio/buffer.h>
Public Member Functions | |
~buffer () override | |
buffer_mapping_type | get_mapping_type () |
return the buffer's mapping type More... | |
virtual int | space_available ()=0 |
return number of items worth of space available for writing More... | |
unsigned int | bufsize () const |
return size of this buffer in items More... | |
const char * | base () const |
return the base address of the buffer More... | |
virtual void * | write_pointer () |
return pointer to write buffer. More... | |
virtual const void * | _read_pointer (unsigned int read_index) |
return pointer to read buffer. More... | |
void | update_write_pointer (int nitems) |
tell buffer that we wrote nitems into it More... | |
void | set_done (bool done) |
bool | done () const |
block_sptr | link () |
Return the block that writes to this buffer. More... | |
size_t | nreaders () const |
buffer_reader * | reader (size_t index) |
gr::thread::mutex * | mutex () |
uint64_t | nitems_written () |
void | reset_nitem_counter () |
size_t | get_sizeof_item () |
uint64_t | get_downstream_lcm_nitems () |
uint32_t | get_max_reader_output_multiple () |
virtual void | update_reader_block_history (unsigned history, int delay) |
void | add_item_tag (const tag_t &tag) |
Adds a new tag to the buffer. More... | |
void | remove_item_tag (const tag_t &tag, long id) |
Removes an existing tag from the buffer. More... | |
void | prune_tags (uint64_t max_time) |
Removes all tags before max_time from buffer. More... | |
std::multimap< uint64_t, tag_t >::iterator | get_tags_begin () |
std::multimap< uint64_t, tag_t >::iterator | get_tags_end () |
std::multimap< uint64_t, tag_t >::iterator | get_tags_lower_bound (uint64_t x) |
std::multimap< uint64_t, tag_t >::iterator | get_tags_upper_bound (uint64_t x) |
virtual void | post_work (int nitems)=0 |
Function to be executed after this object's owner completes the call to general_work() More... | |
virtual bool | input_blkd_cb_ready (int items_required, unsigned read_index) |
Returns true when the current thread is ready to call the callback, false otherwise. Note if input_blocked_callback is overridden then this function should also be overridden. More... | |
virtual bool | input_blocked_callback (int items_required, int items_avail, unsigned read_index) |
Callback function that the scheduler will call when it determines that the input is blocked. Override this function if needed. More... | |
virtual bool | output_blkd_cb_ready (int output_multiple) |
Returns true if the current thread is ready to execute output_blocked_callback(), false otherwise. Note if the default output_blocked_callback is overridden this function should also be overridden. More... | |
virtual bool | output_blocked_callback (int output_multiple, bool force=false) |
Callback function that the scheduler will call when it determines that the output is blocked. Override this function if needed. More... | |
void | increment_active () |
Increment the number of active pointers for this buffer. More... | |
void | decrement_active () |
Decrement the number of active pointers for this buffer and signal anyone waiting when the count reaches zero. More... | |
void | on_lock (gr::thread::scoped_lock &lock) override |
"on_lock" function from the custom_lock_if. More... | |
void | on_unlock () override |
"on_unlock" function from the custom_lock_if. More... | |
void | set_transfer_type (const transfer_type &type) |
Assign buffer's transfer_type. More... | |
Public Member Functions inherited from gr::custom_lock_if | |
virtual | ~custom_lock_if () |
virtual void | on_lock (gr::thread::scoped_lock &lock)=0 |
virtual void | on_unlock ()=0 |
Public Attributes | |
gr::logger_ptr | d_logger |
gr::logger_ptr | d_debug_logger |
Protected Member Functions | |
virtual unsigned | index_add (unsigned a, unsigned b)=0 |
Increment read or write index for this buffer. More... | |
virtual unsigned | index_sub (unsigned a, unsigned b)=0 |
Decrement read or write index for this buffer. More... | |
virtual bool | allocate_buffer (int nitems) |
buffer (buffer_mapping_type buftype, int nitems, size_t sizeof_item, uint64_t downstream_lcm_nitems, uint32_t downstream_max_out_mult, block_sptr link) | |
constructor is private. Use gr_make_buffer to create instances. More... | |
void | drop_reader (buffer_reader *reader) |
disassociate reader from this buffer More... | |
Protected Attributes | |
char * | d_base |
unsigned int | d_bufsize |
buffer_mapping_type | d_buf_map_type |
unsigned | d_max_reader_delay |
unsigned | d_max_reader_history |
bool | d_has_history |
size_t | d_sizeof_item |
std::vector< buffer_reader * > | d_readers |
std::weak_ptr< block > | d_link |
gr::thread::mutex | d_mutex |
unsigned int | d_write_index |
uint64_t | d_abs_write_offset |
bool | d_done |
std::multimap< uint64_t, tag_t > | d_item_tags |
uint64_t | d_last_min_items_read |
gr::thread::condition_variable | d_cv |
bool | d_callback_flag |
uint32_t | d_active_pointer_counter |
uint64_t | d_downstream_lcm_nitems |
uint64_t | d_write_multiple |
uint32_t | d_max_reader_output_multiple |
transfer_type | d_transfer_type |
Friends | |
class | buffer_reader |
class | buffer_reader_sm |
std::ostream & | operator<< (std::ostream &os, const buffer &buf) |
GR_RUNTIME_API buffer_sptr | make_buffer (int nitems, size_t sizeof_item, uint64_t downstream_lcm_nitems, block_sptr link) |
GR_RUNTIME_API buffer_reader_sptr | buffer_add_reader (buffer_sptr buf, int nzero_preload, block_sptr link, int delay) |
Create a new gr::buffer_reader and attach it to buffer buf . More... | |
Single writer, multiple reader fifo.
|
override |
|
protected |
constructor is private. Use gr_make_buffer to create instances.
Allocate a buffer that holds at least nitems
of size sizeof_item
.
buftype | is an enum type that describes the buffer TODO: fix me |
nitems | is the minimum number of items the buffer will hold. |
sizeof_item | is the size of an item in bytes. |
downstream_lcm_nitems | is the least common multiple of the items to read by downstream block(s) |
downstream_max_out_mult | is the maximum output multiple of all downstream blocks |
link | is the block that writes to this buffer. |
The total size of the buffer will be rounded up to a system dependent boundary. This is typically the system page size, but under MS windows is 64KB.
|
virtual |
return pointer to read buffer.
The return value points to at least items_available() items.
Reimplemented in gr::host_buffer.
void gr::buffer::add_item_tag | ( | const tag_t & | tag | ) |
Adds a new tag to the buffer.
tag | the new tag |
|
inlineprotectedvirtual |
Reimplemented in gr::buffer_double_mapped, and gr::buffer_single_mapped.
|
inline |
return the base address of the buffer
|
inline |
return size of this buffer in items
|
inline |
Decrement the number of active pointers for this buffer and signal anyone waiting when the count reaches zero.
|
inline |
|
protected |
disassociate reader
from this buffer
|
inline |
|
inline |
return the buffer's mapping type
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Increment the number of active pointers for this buffer.
|
protectedpure virtual |
Increment read or write index for this buffer.
Implemented in gr::buffer_double_mapped, and gr::buffer_single_mapped.
|
protectedpure virtual |
Decrement read or write index for this buffer.
Implemented in gr::buffer_double_mapped, and gr::buffer_single_mapped.
|
inlinevirtual |
Returns true when the current thread is ready to call the callback, false otherwise. Note if input_blocked_callback is overridden then this function should also be overridden.
Reimplemented in gr::buffer_single_mapped.
|
inlinevirtual |
Callback function that the scheduler will call when it determines that the input is blocked. Override this function if needed.
Reimplemented in gr::host_buffer, and gr::buffer_single_mapped.
|
inline |
Return the block that writes to this buffer.
|
inline |
|
inline |
|
inline |
|
overridevirtual |
"on_lock" function from the custom_lock_if.
Implements gr::custom_lock_if.
|
overridevirtual |
"on_unlock" function from the custom_lock_if.
Implements gr::custom_lock_if.
|
inlinevirtual |
Returns true if the current thread is ready to execute output_blocked_callback(), false otherwise. Note if the default output_blocked_callback is overridden this function should also be overridden.
Reimplemented in gr::buffer_single_mapped.
|
inlinevirtual |
Callback function that the scheduler will call when it determines that the output is blocked. Override this function if needed.
Reimplemented in gr::host_buffer, and gr::buffer_single_mapped.
|
pure virtual |
Function to be executed after this object's owner completes the call to general_work()
Implemented in gr::buffer_double_mapped, and gr::host_buffer.
void gr::buffer::prune_tags | ( | uint64_t | max_time | ) |
Removes all tags before max_time
from buffer.
max_time | the time (item number) to trim up until. |
|
inline |
void gr::buffer::remove_item_tag | ( | const tag_t & | tag, |
long | id | ||
) |
Removes an existing tag from the buffer.
If no such tag is found, does nothing. Note: Doesn't actually physically delete the tag, but marks it as deleted. For the user, this has the same effect: Any subsequent calls to get_tags_in_range() will not return the tag.
tag | the tag that needs to be removed |
id | the unique ID of the block calling this function |
|
inline |
void gr::buffer::set_done | ( | bool | done | ) |
void gr::buffer::set_transfer_type | ( | const transfer_type & | type | ) |
Assign buffer's transfer_type.
|
pure virtual |
return number of items worth of space available for writing
Implemented in gr::buffer_double_mapped, and gr::buffer_single_mapped.
|
inlinevirtual |
Reimplemented in gr::buffer_single_mapped.
void gr::buffer::update_write_pointer | ( | int | nitems | ) |
tell buffer that we wrote nitems
into it
|
virtual |
return pointer to write buffer.
The return value points at space that can hold at least space_available() items.
Reimplemented in gr::host_buffer.
|
friend |
Create a new gr::buffer_reader and attach it to buffer buf
.
buf | is the buffer the gr::buffer_reader reads from. |
nzero_preload | – number of zero items to "preload" into buffer. |
link | is the block that reads from the buffer using this gr::buffer_reader. |
delay | Optional setting to declare the buffer's sample delay. |
|
friend |
|
friend |
|
friend |
|
friend |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
gr::logger_ptr gr::buffer::d_debug_logger |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
gr::logger_ptr gr::buffer::d_logger |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |