diff options
author | Josh Blum | 2013-04-14 02:07:40 -0700 |
---|---|---|
committer | Josh Blum | 2013-04-14 02:07:40 -0700 |
commit | 277dd31b08afcadceec7852012aa8b3c2cecbea7 (patch) | |
tree | b5c06f46c13365dbe2489638496d867221e3ef8c /lib/block_consume.cpp | |
parent | 82af15c5e7a69b116214cb6de99f9095852934d0 (diff) | |
download | sandhi-277dd31b08afcadceec7852012aa8b3c2cecbea7.tar.gz sandhi-277dd31b08afcadceec7852012aa8b3c2cecbea7.tar.bz2 sandhi-277dd31b08afcadceec7852012aa8b3c2cecbea7.zip |
gras: move code into component files
Diffstat (limited to 'lib/block_consume.cpp')
-rw-r--r-- | lib/block_consume.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/lib/block_consume.cpp b/lib/block_consume.cpp new file mode 100644 index 0000000..efdb07e --- /dev/null +++ b/lib/block_consume.cpp @@ -0,0 +1,44 @@ +// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information. + +#include "element_impl.hpp" +#include <gras_impl/block_actor.hpp> +#include <gras/block.hpp> +#include "tag_handlers.hpp" + +using namespace gras; + +void Block::consume(const size_t which_input, const size_t num_items) +{ + ASSERT(long(num_items) >= 0); //sign bit set? you dont want a negative + (*this)->block->consume(which_input, num_items); +} + +void Block::consume(const size_t num_items) +{ + const size_t num_inputs = (*this)->block->get_num_inputs(); + for (size_t i = 0; i < num_inputs; i++) + { + (*this)->block->consume(i, num_items); + } +} + +item_index_t Block::get_consumed(const size_t which_input) +{ + return (*this)->block->stats.items_consumed[which_input]; +} + +SBuffer Block::get_input_buffer(const size_t which_input) const +{ + return (*this)->block->input_queues.front(which_input); +} + +GRAS_FORCE_INLINE void BlockActor::consume(const size_t i, const size_t items) +{ + #ifdef ITEM_CONSPROD + std::cerr << name << " consume " << items << std::endl; + #endif + this->stats.items_consumed[i] += items; + const size_t bytes = items*this->input_configs[i].item_size; + this->input_queues.consume(i, bytes); + this->trim_tags(i); +} |