diff options
author | Josh Blum | 2012-11-18 18:14:21 -0800 |
---|---|---|
committer | Josh Blum | 2012-11-18 18:14:21 -0800 |
commit | 308a2403b23888c3f1d2b1ff3b579c1b17450cf1 (patch) | |
tree | a839ca3e3166d9dea9dfc4ecd21daef4cdd42eb4 /lib/gras_impl | |
parent | 4f9768f88eeed0c0b7e6ce7335752475d6a20df1 (diff) | |
download | sandhi-308a2403b23888c3f1d2b1ff3b579c1b17450cf1.tar.gz sandhi-308a2403b23888c3f1d2b1ff3b579c1b17450cf1.tar.bz2 sandhi-308a2403b23888c3f1d2b1ff3b579c1b17450cf1.zip |
support for null buffers when reserve == 0
Diffstat (limited to 'lib/gras_impl')
-rw-r--r-- | lib/gras_impl/input_buffer_queues.hpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/lib/gras_impl/input_buffer_queues.hpp b/lib/gras_impl/input_buffer_queues.hpp index c0148a8..86483f3 100644 --- a/lib/gras_impl/input_buffer_queues.hpp +++ b/lib/gras_impl/input_buffer_queues.hpp @@ -21,6 +21,22 @@ struct InputBufferQueues enum {MAX_QUEUE_SIZE = 128}; enum {MAX_AUX_BUFF_BYTES=(1<<16)}; + static SBuffer make_null_buff(void) + { + SBufferConfig config; + config.memory = NULL; + config.length = 1; + return SBuffer(config); + } + + static SBuffer &get_null_buff(void) + { + static SBuffer null = make_null_buff(); + null.offset = 0; + null.length = 0; + return null; + } + ~InputBufferQueues(void) { this->resize(0); @@ -31,9 +47,11 @@ struct InputBufferQueues //! Call to get an input buffer for work GRAS_FORCE_INLINE SBuffer &front(const size_t i) { - ASSERT(not _queues[i].empty()); ASSERT(this->ready(i)); + //special case when the null buffer is possible + if (_queues[i].empty()) return get_null_buff(); + return _queues[i].front(); } |