summaryrefslogtreecommitdiff
path: root/lib/gras_impl
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/gras_impl
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/gras_impl')
-rw-r--r--lib/gras_impl/block_actor.hpp21
-rw-r--r--lib/gras_impl/output_buffer_queues.hpp13
2 files changed, 13 insertions, 21 deletions
diff --git a/lib/gras_impl/block_actor.hpp b/lib/gras_impl/block_actor.hpp
index 2799313..5444bb0 100644
--- a/lib/gras_impl/block_actor.hpp
+++ b/lib/gras_impl/block_actor.hpp
@@ -104,7 +104,6 @@ struct BlockActor : Apology::Worker
void produce(const size_t index, const size_t items);
void consume(const size_t index, const size_t items);
void produce_buffer(const size_t index, const SBuffer &buffer);
- void flush_output(const size_t index);
void task_kicker(void);
void update_input_avail(const size_t index);
bool is_input_done(const size_t index);
@@ -168,26 +167,6 @@ struct BlockActor : Apology::Worker
//-------------- common functions from this BlockActor class ---------//
-GRAS_FORCE_INLINE void BlockActor::flush_output(const size_t i)
-{
- if GRAS_UNLIKELY(this->output_queues.empty(i) or this->output_queues.front(i).length == 0) return;
- SBuffer &buff = this->output_queues.front(i);
- if GRAS_LIKELY(this->produce_outputs[i])
- {
- this->produce_outputs[i] = false;
- InputBufferMessage buff_msg;
- buff_msg.buffer = buff;
- this->post_downstream(i, buff_msg);
- }
-
- //increment buffer for next use
- buff.offset += buff.length;
- buff.length = 0;
-
- //release whatever has been used of the output buffer
- this->output_queues.pop(i);
-}
-
GRAS_FORCE_INLINE void BlockActor::task_kicker(void)
{
if (this->is_work_allowed()) this->Send(SelfKickMessage(), this->GetAddress());
diff --git a/lib/gras_impl/output_buffer_queues.hpp b/lib/gras_impl/output_buffer_queues.hpp
index deea0e1..251de96 100644
--- a/lib/gras_impl/output_buffer_queues.hpp
+++ b/lib/gras_impl/output_buffer_queues.hpp
@@ -53,6 +53,19 @@ struct OutputBufferQueues
return _queues[i]->front();
}
+ GRAS_FORCE_INLINE void consume(const size_t i)
+ {
+ ASSERT(not this->empty(i));
+ SBuffer &buff = this->front(i);
+ if GRAS_UNLIKELY(buff.length == 0) return;
+
+ //increment buffer for next use
+ buff.offset += buff.length;
+ buff.length = 0;
+
+ this->pop(i);
+ }
+
GRAS_FORCE_INLINE void pop(const size_t i)
{
ASSERT(_queues[i]);