summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJosh Blum2012-09-24 00:07:31 -0400
committerJosh Blum2012-09-24 00:07:31 -0400
commit932ca4ad29be0bf2b33bf31b5723afb4c0e81f0b (patch)
tree558eba1ac92eb1ad2ff4c97963f174e725992f82 /lib
parent37d94b9717b11aea0f26905857bf3676589d43e9 (diff)
downloadsandhi-932ca4ad29be0bf2b33bf31b5723afb4c0e81f0b.tar.gz
sandhi-932ca4ad29be0bf2b33bf31b5723afb4c0e81f0b.tar.bz2
sandhi-932ca4ad29be0bf2b33bf31b5723afb4c0e81f0b.zip
restore history residual code to escape mini buffs
Diffstat (limited to 'lib')
-rw-r--r--lib/gras_impl/input_buffer_queues.hpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/gras_impl/input_buffer_queues.hpp b/lib/gras_impl/input_buffer_queues.hpp
index 50a06ef..c692e2b 100644
--- a/lib/gras_impl/input_buffer_queues.hpp
+++ b/lib/gras_impl/input_buffer_queues.hpp
@@ -105,6 +105,7 @@ struct InputBufferQueues
std::vector<size_t> _multiple_bytes;
std::vector<size_t> _post_bytes;
std::vector<boost::shared_ptr<BufferQueue> > _aux_queues;
+ std::vector<bool> _in_aux_buff;
};
@@ -118,6 +119,7 @@ GRAS_FORCE_INLINE void InputBufferQueues::resize(const size_t size)
_multiple_bytes.resize(size, 0);
_post_bytes.resize(size, 0);
_aux_queues.resize(size);
+ _in_aux_buff.resize(size, false);
}
static size_t round_up_to_multiple(const size_t at_least, const size_t multiple)
@@ -181,6 +183,7 @@ GRAS_FORCE_INLINE void InputBufferQueues::init(
buff.length = delta;
this->push(i, buff);
+ _in_aux_buff[i] = true;
}
if (_history_bytes[i] < old_history)
{
@@ -242,6 +245,7 @@ GRAS_FORCE_INLINE void InputBufferQueues::__prepare(const size_t i)
_aux_queues[i]->pop();
dst.offset = 0;
dst.length = 0;
+ _in_aux_buff[i] = true;
}
SBuffer src = _queues[i].front();
@@ -282,6 +286,16 @@ GRAS_FORCE_INLINE void InputBufferQueues::consume(const size_t i, const size_t b
_queues[i].pop_front();
}
+ else if (_in_aux_buff[i] and _queues[i].front().offset >= 2*_history_bytes[i])
+ {
+ _in_aux_buff[i] = false;
+ const size_t residual = _queues[i].front().length;
+ _queues[i].pop_front();
+ ASSERT(not _queues[i].empty());
+ _queues[i].front().length += residual;
+ _queues[i].front().offset -= residual;
+ }
+
//update the number of bytes in this queue
ASSERT(_enqueued_bytes[i] >= bytes_consumed);
_enqueued_bytes[i] -= bytes_consumed;