summaryrefslogtreecommitdiff
path: root/lib/task_main.cpp
diff options
context:
space:
mode:
authorJosh Blum2013-04-27 13:05:09 -0700
committerJosh Blum2013-04-27 13:05:09 -0700
commit2464a5780736b71c23cc46d031a62ff30e35d969 (patch)
treed6f2a0e66a06b81219f3a6006bf5f1bae8f8c16b /lib/task_main.cpp
parentcf930158eabb585552c9b2691370c5ceb7fc6d76 (diff)
downloadsandhi-2464a5780736b71c23cc46d031a62ff30e35d969.tar.gz
sandhi-2464a5780736b71c23cc46d031a62ff30e35d969.tar.bz2
sandhi-2464a5780736b71c23cc46d031a62ff30e35d969.zip
gras: moved flush output to consume function in output queues
This cleans up some code in block actor. The message sending code is now in task_main, and the consume routine is now the shared one.
Diffstat (limited to 'lib/task_main.cpp')
-rw-r--r--lib/task_main.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib/task_main.cpp b/lib/task_main.cpp
index 9ab786a..6c3c23d 100644
--- a/lib/task_main.cpp
+++ b/lib/task_main.cpp
@@ -52,7 +52,7 @@ void BlockActor::task_main(void)
//copy buffer reference but push with zero length, same offset
SBuffer new_obuff = buff;
new_obuff.length = 0;
- this->flush_output(output_inline_index);
+ this->output_queues.consume(output_inline_index);
this->output_queues.push(output_inline_index, new_obuff); //you got inlined!
output_inline_index++; //done do this output port again
}
@@ -103,7 +103,19 @@ void BlockActor::task_main(void)
//------------------------------------------------------------------
for (size_t i = 0; i < num_outputs; i++)
{
- this->flush_output(i);
+ //buffer may be popped by one of the special buffer api hooks
+ if GRAS_UNLIKELY(this->output_queues.empty(i)) continue;
+
+ //grab a copy of the front buffer then consume from the queue
+ InputBufferMessage buff_msg;
+ buff_msg.buffer = this->output_queues.front(i);
+ this->output_queues.consume(i);
+
+ //Post a buffer message downstream only if the produce flag was marked.
+ //So this explicitly after consuming the output queues so pop is called.
+ //This is because pop may have special hooks in it to prepare the buffer.
+ if GRAS_LIKELY(this->produce_outputs[i]) this->post_downstream(i, buff_msg);
+ this->produce_outputs[i] = false;
}
//------------------------------------------------------------------