diff options
author | Josh Blum | 2012-11-26 04:30:39 -0800 |
---|---|---|
committer | Josh Blum | 2012-11-26 04:30:39 -0800 |
commit | 7fe33bd6aba762549d05ace9f66d5cf29530aa76 (patch) | |
tree | 7846696810f4cef8425c0ad2ca45fbde3db16ded /lib/gras_impl | |
parent | 267e942a0d1a63388a5ee0a112b9d16158f1b1cc (diff) | |
download | sandhi-7fe33bd6aba762549d05ace9f66d5cf29530aa76.tar.gz sandhi-7fe33bd6aba762549d05ace9f66d5cf29530aa76.tar.bz2 sandhi-7fe33bd6aba762549d05ace9f66d5cf29530aa76.zip |
reset queue ref before pop
Diffstat (limited to 'lib/gras_impl')
-rw-r--r-- | lib/gras_impl/input_buffer_queues.hpp | 14 | ||||
-rw-r--r-- | lib/gras_impl/output_buffer_queues.hpp | 1 |
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/gras_impl/input_buffer_queues.hpp b/lib/gras_impl/input_buffer_queues.hpp index aa097ff..80f350b 100644 --- a/lib/gras_impl/input_buffer_queues.hpp +++ b/lib/gras_impl/input_buffer_queues.hpp @@ -59,6 +59,8 @@ struct InputBufferQueues } ASSERT(_queues[i].front().length >= _reserve_bytes[i]); + ASSERT((_queues[i].front().length % _items_sizes[i]) == 0); + return _queues[i].front(); } @@ -86,6 +88,13 @@ struct InputBufferQueues return _queues[i].front().length >= _maximum_bytes[i]; } + GRAS_FORCE_INLINE void pop(const size_t i) + { + ASSERT(not _queues[i].empty()); + _queues[i].front().reset(); + _queues[i].pop_front(); + } + GRAS_FORCE_INLINE void push(const size_t i, const SBuffer &buffer) { ASSERT(not _queues[i].full()); @@ -245,7 +254,7 @@ GRAS_FORCE_INLINE void InputBufferQueues::accumulate(const size_t i) free_bytes -= bytes; front.length -= bytes; front.offset += bytes; - if (front.length == 0) _queues[i].pop_front(); + if (front.length == 0) this->pop(i); } _queues[i].push_front(accum_buff); @@ -267,7 +276,8 @@ GRAS_FORCE_INLINE void InputBufferQueues::consume(const size_t i, const size_t b front.offset += bytes_consumed; front.length -= bytes_consumed; ASSERT(front.offset <= front.get_actual_length()); - if (front.length == 0) _queues[i].pop_front(); + ASSERT((_queues[i].front().length % _items_sizes[i]) == 0); + if (front.length == 0) this->pop(i); //update the number of bytes in this queue ASSERT(_enqueued_bytes[i] >= bytes_consumed); diff --git a/lib/gras_impl/output_buffer_queues.hpp b/lib/gras_impl/output_buffer_queues.hpp index 383d88a..c432f4d 100644 --- a/lib/gras_impl/output_buffer_queues.hpp +++ b/lib/gras_impl/output_buffer_queues.hpp @@ -51,6 +51,7 @@ struct OutputBufferQueues GRAS_FORCE_INLINE void pop(const size_t i) { + _queues[i].front() = T(); _queues[i].pop_front(); _bitset.set(i, not _queues[i].empty()); } |