From 734c3740c4ddccfbedf697edbd39021580fd51ce Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Sat, 4 May 2013 20:42:09 -0700 Subject: gras: implement force done input port option fixes #28 --- PMC | 2 +- grextras | 2 +- include/gras/block.hpp | 16 ++++++++++++++++ lib/block.cpp | 1 + lib/gras_impl/block_actor.hpp | 4 +++- 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/PMC b/PMC index 6b44492..060c765 160000 --- a/PMC +++ b/PMC @@ -1 +1 @@ -Subproject commit 6b444922db565cd64b39729a8129eac7c81fe0cd +Subproject commit 060c76567c4e0adeee089dd8e060befdff295f63 diff --git a/grextras b/grextras index 07fbc56..643da81 160000 --- a/grextras +++ b/grextras @@ -1 +1 @@ -Subproject commit 07fbc5681cc4dcd2813ff7a1ef8fd1632085964c +Subproject commit 643da81a652a38afe10201390ab343667d10ae82 diff --git a/include/gras/block.hpp b/include/gras/block.hpp index 8cb5f95..5f51acf 100644 --- a/include/gras/block.hpp +++ b/include/gras/block.hpp @@ -76,6 +76,22 @@ struct GRAS_API InputPortConfig * Default = 0. */ size_t preload_items; + + /*! + * Force this block done when input port is done. + * When the upstream feeding this port declares done, + * this block will mark done once upstream notifies. + * The primary usage is to modify the done logic + * for the purposes of unit test confiruability. + * + * If the force done option is false, the block will + * not mark done when this port's upstream is done. + * However, this block will mark done when all + * input ports are done, reguardless of this setting. + * + * Default = true. + */ + bool force_done; }; //! Configuration parameters for an output port diff --git a/lib/block.cpp b/lib/block.cpp index 0015f10..75af20c 100644 --- a/lib/block.cpp +++ b/lib/block.cpp @@ -14,6 +14,7 @@ InputPortConfig::InputPortConfig(void) maximum_items = 0; inline_buffer = false; preload_items = 0; + force_done = true; } OutputPortConfig::OutputPortConfig(void) diff --git a/lib/gras_impl/block_actor.hpp b/lib/gras_impl/block_actor.hpp index 5444bb0..e5dbaac 100644 --- a/lib/gras_impl/block_actor.hpp +++ b/lib/gras_impl/block_actor.hpp @@ -182,7 +182,9 @@ GRAS_FORCE_INLINE void BlockActor::update_input_avail(const size_t i) GRAS_FORCE_INLINE bool BlockActor::is_input_done(const size_t i) { - return this->inputs_done[i] and not this->inputs_available[i]; + const bool force_done = this->input_configs[i].force_done; + if GRAS_LIKELY(force_done) return this->inputs_done[i] and not this->inputs_available[i]; + return this->inputs_done.all() and this->inputs_available.none(); } GRAS_FORCE_INLINE bool BlockActor::is_work_allowed(void) -- cgit