summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJosh Blum2012-12-15 22:37:10 -0800
committerJosh Blum2012-12-15 22:37:10 -0800
commitdb2933a31db9983cc24d925f5b86db43a466ad36 (patch)
tree7cb6870122addcc8d6ff287c38a4ca0bfb9b5c16 /lib
parentbe0a690b4a6f585e13df0a89b8dce1dc47998c4d (diff)
downloadsandhi-db2933a31db9983cc24d925f5b86db43a466ad36.tar.gz
sandhi-db2933a31db9983cc24d925f5b86db43a466ad36.tar.bz2
sandhi-db2933a31db9983cc24d925f5b86db43a466ad36.zip
misc fixes to buffer rework
Diffstat (limited to 'lib')
-rw-r--r--lib/block_task.cpp6
-rw-r--r--lib/buffer_queue_circ.cpp8
-rw-r--r--lib/buffer_queue_pool.cpp10
-rw-r--r--lib/gras_impl/output_buffer_queues.hpp45
4 files changed, 36 insertions, 33 deletions
diff --git a/lib/block_task.cpp b/lib/block_task.cpp
index 6b18798..cc9d6af 100644
--- a/lib/block_task.cpp
+++ b/lib/block_task.cpp
@@ -274,6 +274,10 @@ GRAS_FORCE_INLINE void BlockActor::flush_output(const size_t i, const bool force
buff.offset += buff.length;
buff.length = 0;
+ //simply just pop
+ this->output_queues.pop(i);
+
+ /*
//when to pop the buffer and give next work a new one
const size_t reserve_bytes = this->output_configs[i].reserve_items/this->output_items_sizes[i];
if (
@@ -282,5 +286,5 @@ GRAS_FORCE_INLINE void BlockActor::flush_output(const size_t i, const bool force
)
{
this->output_queues.pop(i);
- }
+ }*/
}
diff --git a/lib/buffer_queue_circ.cpp b/lib/buffer_queue_circ.cpp
index 9d0dbcf..41a31c7 100644
--- a/lib/buffer_queue_circ.cpp
+++ b/lib/buffer_queue_circ.cpp
@@ -1,3 +1,11 @@
// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information.
#include <gras/buffer_queue.hpp>
+
+using namespace gras;
+
+BufferQueueSptr BufferQueue::make_circ(
+ const SBufferConfig &config
+){
+
+}
diff --git a/lib/buffer_queue_pool.cpp b/lib/buffer_queue_pool.cpp
index a30f4a6..a2a4c28 100644
--- a/lib/buffer_queue_pool.cpp
+++ b/lib/buffer_queue_pool.cpp
@@ -8,13 +8,16 @@ using namespace gras;
struct BufferQueuePool : BufferQueue
{
- BufferQueuePool(const size_t num)
+ BufferQueuePool(const size_t num):
+ queue(boost::circular_buffer<SBuffer>(num))
{
- queue.resize(num);
+ //NOP
}
SBuffer &front(void)
{
+ ASSERT(not queue.empty());
+ ASSERT(queue.front());
return queue.front();
}
@@ -27,6 +30,7 @@ struct BufferQueuePool : BufferQueue
void push(const SBuffer &buff)
{
+ ASSERT(buff);
queue.push_back(buff);
}
@@ -48,7 +52,7 @@ BufferQueueSptr BufferQueue::make_pool(
{
SBuffer buff(config);
std::memset(buff.get_actual_memory(), 0, buff.get_actual_length());
- bq->push(buff);
+ //bq->push(buff);
}
return bq;
}
diff --git a/lib/gras_impl/output_buffer_queues.hpp b/lib/gras_impl/output_buffer_queues.hpp
index d9cd5e4..27a6175 100644
--- a/lib/gras_impl/output_buffer_queues.hpp
+++ b/lib/gras_impl/output_buffer_queues.hpp
@@ -22,7 +22,7 @@ struct OutputBufferQueues
void set_reserve_bytes(const size_t i, const size_t num_bytes)
{
_reserve_bytes[i] = num_bytes;
- _update(i);
+ if (_queues[i]) _update(i);
}
GRAS_FORCE_INLINE void resize(const size_t size)
@@ -32,9 +32,11 @@ struct OutputBufferQueues
_reserve_bytes.resize(size, 1);
}
- GRAS_FORCE_INLINE void push(const size_t i, const SBuffer &value)
+ GRAS_FORCE_INLINE void push(const size_t i, const SBuffer &buff)
{
- _queues[i]->push(value);
+ ASSERT(buff);
+ ASSERT(_queues[i]);
+ _queues[i]->push(buff);
_update(i);
}
@@ -45,16 +47,6 @@ struct OutputBufferQueues
this->resize(old_size);
}
- //! used for input buffer inlining
- /*
- GRAS_FORCE_INLINE void push_front(const size_t i, const T &value)
- {
- ASSERT(not _queues[i].full());
- _queues[i].push_front(value);
- _bitset.set(i);
- }
- */
-
GRAS_FORCE_INLINE SBuffer &front(const size_t i)
{
ASSERT(not this->empty(i));
@@ -63,6 +55,8 @@ struct OutputBufferQueues
GRAS_FORCE_INLINE void pop(const size_t i)
{
+ ASSERT(_queues[i]);
+ ASSERT(not _queues[i]->empty());
_queues[i]->pop();
_update(i);
}
@@ -71,24 +65,10 @@ struct OutputBufferQueues
{
_bitset.reset(i);
}
-/*
- GRAS_FORCE_INLINE void flush(const size_t i)
- {
- _queues[i].clear();
- _bitset.reset(i);
- }
- GRAS_FORCE_INLINE void flush_all(void)
- {
- for (size_t i = 0; i < this->size(); i++) this->flush(i);
- }
-*/
GRAS_FORCE_INLINE bool ready(const size_t i) const
{
- if (_queues[i]->empty()) return false;
- const SBuffer &front = _queues[i]->front();
- const size_t avail = front.get_actual_length() - front.offset - front.length;
- return avail >= _reserve_bytes[i];
+ return _bitset[i];
}
GRAS_FORCE_INLINE bool empty(const size_t i) const
@@ -109,7 +89,14 @@ struct OutputBufferQueues
GRAS_FORCE_INLINE void _update(const size_t i)
{
- _bitset.set(i, this->ready(i));
+ if (not _queues[i] or _queues[i]->empty())
+ {
+ _bitset.reset(i);
+ return;
+ }
+ const SBuffer &front = _queues[i]->front();
+ const size_t avail = front.get_actual_length() - front.offset - front.length;
+ _bitset.set(i, avail >= _reserve_bytes[i]);
}
BitSet _bitset;