summaryrefslogtreecommitdiff
path: root/lib/block.cpp
diff options
context:
space:
mode:
authorJosh Blum2013-01-18 18:25:06 -0800
committerJosh Blum2013-01-18 18:25:06 -0800
commit0a8e3475a6606620a9ad588074da713fb93e1188 (patch)
tree767ddbd27d17d948449a889f5293f6cd05078263 /lib/block.cpp
parentf8fdedcf8e89179794eac7ca8d8b8550e87ac9bd (diff)
downloadsandhi-0a8e3475a6606620a9ad588074da713fb93e1188.tar.gz
sandhi-0a8e3475a6606620a9ad588074da713fb93e1188.tar.bz2
sandhi-0a8e3475a6606620a9ad588074da713fb93e1188.zip
address that pop vs get output buffer issue
Diffstat (limited to 'lib/block.cpp')
-rw-r--r--lib/block.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/block.cpp b/lib/block.cpp
index 21e2d36..716873b 100644
--- a/lib/block.cpp
+++ b/lib/block.cpp
@@ -229,23 +229,25 @@ void Block::mark_done(void)
(*this)->block->mark_done();
}
-const SBuffer &Block::get_input_buffer(const size_t which_input) const
+SBuffer Block::get_input_buffer(const size_t which_input) const
{
return (*this)->block->input_queues.front(which_input);
}
-SBuffer Block::pop_output_buffer(const size_t which_output)
+SBuffer Block::get_output_buffer(const size_t which_output) const
{
- SBuffer buff = (*this)->block->output_queues.front(which_output);
- //set the offset on the buffer to be popped so that something will be removed
- //TODO this basically addresses popping on the circ buff,
- //but perhaps there is a better API for output buffer access.
- //like using get_output_buffer() + pop(some length)
- (*this)->block->output_queues.front(which_output).offset = buff.get_actual_length();
- (*this)->block->output_queues.pop(which_output);
+ SBuffer &buff = (*this)->block->output_queues.front(which_output);
+ //increment length to auto pop full buffer size,
+ //when user doesnt call pop_output_buffer()
+ buff.length = buff.get_actual_length();
return buff;
}
+void Block::pop_output_buffer(const size_t which_output, const size_t num_bytes)
+{
+ (*this)->block->output_queues.front(which_output).length = num_bytes;
+}
+
void Block::post_output_buffer(const size_t which_output, const SBuffer &buffer)
{
(*this)->block->produce_buffer(which_output, buffer);