diff options
author | Josh Blum | 2012-10-01 19:43:52 -0700 |
---|---|---|
committer | Josh Blum | 2012-10-01 19:43:52 -0700 |
commit | 29a2a6679ba8c149b1220d06225abaf89d8c88f0 (patch) | |
tree | bdf9fab2f8776cde933e889b4b7659403f89e9af /lib/gras_impl/output_buffer_queues.hpp | |
parent | 8e224b5da13783bfd89eccd356b030146d02396d (diff) | |
download | sandhi-29a2a6679ba8c149b1220d06225abaf89d8c88f0.tar.gz sandhi-29a2a6679ba8c149b1220d06225abaf89d8c88f0.tar.bz2 sandhi-29a2a6679ba8c149b1220d06225abaf89d8c88f0.zip |
switch to fixed size queue to avoid runtime allocs
Diffstat (limited to 'lib/gras_impl/output_buffer_queues.hpp')
-rw-r--r-- | lib/gras_impl/output_buffer_queues.hpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/gras_impl/output_buffer_queues.hpp b/lib/gras_impl/output_buffer_queues.hpp index 18eb551..69c5eb0 100644 --- a/lib/gras_impl/output_buffer_queues.hpp +++ b/lib/gras_impl/output_buffer_queues.hpp @@ -19,7 +19,7 @@ #include <gras_impl/bitset.hpp> #include <vector> -#include <deque> +#include <boost/circular_buffer.hpp> namespace gnuradio { @@ -27,13 +27,15 @@ namespace gnuradio template <typename T> struct OutputBufferQueues { + enum {MAX_QUEUE_SIZE = 128}; + BitSet _bitset; - std::vector<std::deque<T> > _queues; + std::vector<boost::circular_buffer<T> > _queues; GRAS_FORCE_INLINE void resize(const size_t size) { _bitset.resize(size); - _queues.resize(size); + _queues.resize(size, boost::circular_buffer<T>(MAX_QUEUE_SIZE)); } GRAS_FORCE_INLINE void push(const size_t i, const T &value) @@ -45,6 +47,7 @@ struct OutputBufferQueues //! used for input buffer inlining GRAS_FORCE_INLINE void push_front(const size_t i, const T &value) { + ASSERT(not _queues[i].full()); _queues[i].push_front(value); _bitset.set(i); } @@ -67,7 +70,7 @@ struct OutputBufferQueues GRAS_FORCE_INLINE void flush(const size_t i) { - _queues[i] = std::deque<T>(); + _queues[i].clear(); _bitset.reset(i); } |