diff options
author | Josh Blum | 2012-09-06 23:20:15 -0700 |
---|---|---|
committer | Josh Blum | 2012-09-06 23:20:15 -0700 |
commit | 77485f255b040846890c3c64d764e00f5de5cfe2 (patch) | |
tree | 7d2c97c07cc334dd61054249d6309ad56c90effd /lib/gras_impl/buffer_queue.hpp | |
parent | f84970693f4e1c9919e139c1d99daa74691b5a46 (diff) | |
download | sandhi-77485f255b040846890c3c64d764e00f5de5cfe2.tar.gz sandhi-77485f255b040846890c3c64d764e00f5de5cfe2.tar.bz2 sandhi-77485f255b040846890c3c64d764e00f5de5cfe2.zip |
work on simplifying buffer queue logic
Diffstat (limited to 'lib/gras_impl/buffer_queue.hpp')
-rw-r--r-- | lib/gras_impl/buffer_queue.hpp | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/lib/gras_impl/buffer_queue.hpp b/lib/gras_impl/buffer_queue.hpp new file mode 100644 index 0000000..e9ac220 --- /dev/null +++ b/lib/gras_impl/buffer_queue.hpp @@ -0,0 +1,64 @@ +// +// Copyright 2012 Josh Blum +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with io_sig program. If not, see <http://www.gnu.org/licenses/>. + +#ifndef INCLUDED_LIBGRAS_IMPL_BUFFER_QUEUE_HPP +#define INCLUDED_LIBGRAS_IMPL_BUFFER_QUEUE_HPP + +#include <tsbe/buffer.hpp> +#include <boost/bind.hpp> +#include <queue> + +namespace gnuradio +{ + +struct BufferQueue : std::queue<tsbe::Buffer> +{ + BufferQueue(void) + { + tsbe::BufferDeleter deleter = boost::bind(&BufferQueue::push, this, _1); + _token = tsbe::BufferToken(new tsbe::BufferDeleter(deleter)); + } + + ~BufferQueue(void) + { + _token.reset(); + this->flush(); + } + + void flush(void) + { + while (not this->empty()) + { + this->pop(); + } + } + + void allocate_one(const size_t num_bytes) + { + tsbe::BufferConfig config; + config.memory = NULL; + config.length = num_bytes; + config.token = _token; + tsbe::Buffer buff(config); + //buffer derefs here and the token messages it back to the queue + } + + tsbe::BufferToken _token; +}; + +} //namespace gnuradio + +#endif /*INCLUDED_LIBGRAS_IMPL_BUFFER_QUEUE_HPP*/ |