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/buffer_queue.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/buffer_queue.hpp')
-rw-r--r-- | lib/gras_impl/buffer_queue.hpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/gras_impl/buffer_queue.hpp b/lib/gras_impl/buffer_queue.hpp index b3c9cf7..e9950b8 100644 --- a/lib/gras_impl/buffer_queue.hpp +++ b/lib/gras_impl/buffer_queue.hpp @@ -19,26 +19,26 @@ #include <gnuradio/sbuffer.hpp> #include <boost/bind.hpp> -#include <queue> +#include <boost/circular_buffer.hpp> namespace gnuradio { -struct BufferQueue : std::queue<SBuffer> +struct BufferQueue : boost::circular_buffer<SBuffer> { + enum {MAX_QUEUE_SIZE = 4}; + BufferQueue(void) { - SBufferDeleter deleter = boost::bind(&BufferQueue::push, this, _1); + this->resize(MAX_QUEUE_SIZE); + SBufferDeleter deleter = boost::bind(&BufferQueue::push_back, this, _1); _token = SBufferToken(new SBufferDeleter(deleter)); } ~BufferQueue(void) { _token.reset(); - while (not this->empty()) - { - this->pop(); - } + this->clear(); } void allocate_one(const size_t num_bytes) |