diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/gras/CMakeLists.txt | 1 | ||||
-rw-r--r-- | include/gras/block.hpp | 9 | ||||
-rw-r--r-- | include/gras/block.i | 1 | ||||
-rw-r--r-- | include/gras/buffer_queue.hpp | 43 |
4 files changed, 50 insertions, 4 deletions
diff --git a/include/gras/CMakeLists.txt b/include/gras/CMakeLists.txt index e8fb85e..f0b0d3a 100644 --- a/include/gras/CMakeLists.txt +++ b/include/gras/CMakeLists.txt @@ -21,6 +21,7 @@ install(FILES thread_pool.hpp top_block.hpp work_buffer.hpp + buffer_queue.hpp DESTINATION include/gras COMPONENT ${GRAS_COMP_DEVEL} diff --git a/include/gras/block.hpp b/include/gras/block.hpp index 3899561..524ff00 100644 --- a/include/gras/block.hpp +++ b/include/gras/block.hpp @@ -8,6 +8,7 @@ #include <gras/tag_iter.hpp> #include <gras/tags.hpp> #include <gras/work_buffer.hpp> +#include <gras/buffer_queue.hpp> #include <vector> #include <string> @@ -337,9 +338,9 @@ struct GRAS_API Block : Element * \param which_output the output port index number * \param token the token for the buffer's returner * \param recommend_length the schedulers recommended length in bytes - * \return the token used for the buffer allocation (may be the same) + * \return a shared ptr to a new buffer queue object */ - virtual SBufferToken output_buffer_allocator( + virtual BufferQueueSptr output_buffer_allocator( const size_t which_output, const SBufferToken &token, const size_t recommend_length @@ -356,9 +357,9 @@ struct GRAS_API Block : Element * \param which_input the input port index number * \param token the token for the buffer's returner * \param recommend_length the schedulers recommended length in bytes - * \return the token used for the buffer allocation (may be the same) + * \return a shared ptr to a new buffer queue object */ - virtual SBufferToken input_buffer_allocator( + virtual BufferQueueSptr input_buffer_allocator( const size_t which_input, const SBufferToken &token, const size_t recommend_length diff --git a/include/gras/block.i b/include/gras/block.i index 80c3905..ef2738c 100644 --- a/include/gras/block.i +++ b/include/gras/block.i @@ -11,6 +11,7 @@ %import <gras/tags.i> %include <gras/tag_iter.i> %import <gras/sbuffer.i> +%include <gras/buffer_queue.hpp> %include <gras/block.hpp> #endif /*INCLUDED_GRAS_BLOCK_I*/ diff --git a/include/gras/buffer_queue.hpp b/include/gras/buffer_queue.hpp new file mode 100644 index 0000000..5125555 --- /dev/null +++ b/include/gras/buffer_queue.hpp @@ -0,0 +1,43 @@ +// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information. + +#ifndef INCLUDED_GRAS_BUFFER_QUEUE_HPP +#define INCLUDED_GRAS_BUFFER_QUEUE_HPP + +#include <gras/gras.hpp> +#include <gras/sbuffer.hpp> +#include <boost/shared_ptr.hpp> + +namespace gras +{ + +struct BufferQueue; + +typedef boost::shared_ptr<BufferQueue> BufferQueueSptr; + +//! Buffer Queue is an interface enabling us to create custom buffer allocators. +struct BufferQueue +{ + + //! Create a buffer queue using the pool allocator + GRAS_API static BufferQueueSptr make_pool(const SBufferConfig &config, const size_t num_buffs); + + //! Create a buffer queue using the circular buffer allocator + GRAS_API static BufferQueueSptr make_circ(const SBufferConfig &config); + + //! Get a reference to the buffer at the front of the queue + virtual SBuffer &front(void) = 0; + + //! Pop off the used portion of the queue + virtual void pop(void) = 0; + + //! Push a used buffer back into the queue + virtual void push(const SBuffer &buff) = 0; + + //! Is the queue empty? + virtual bool empty(void) const = 0; + +}; + +} //namespace gras + +#endif /*INCLUDED_GRAS_BUFFER_QUEUE_HPP*/ |