diff options
author | Josh Blum | 2013-06-20 19:48:29 -0700 |
---|---|---|
committer | Josh Blum | 2013-06-20 19:48:29 -0700 |
commit | 37bd56f3301795e89294c048883324b0353237ef (patch) | |
tree | 77d1a9066c0f416c6758eab154dcf2706e197595 /lib/input_handlers.cpp | |
parent | 630a272e6725a547327366e543106e63c23fd816 (diff) | |
download | sandhi-37bd56f3301795e89294c048883324b0353237ef.tar.gz sandhi-37bd56f3301795e89294c048883324b0353237ef.tar.bz2 sandhi-37bd56f3301795e89294c048883324b0353237ef.zip |
gras: work on goddamn done logic
How blocks mark themselves done has been one of the most annoying things in this development.
This done logic is only valuable for QA tests, it doesnt even exist in the practical use case.
How it works now:
* blocks mark done when sync inputs are done or all inputs are done
* removed the force_done input config, its no longer needed
* the wait() implementation gives blocks a grace period between
an input becoming done and the block itself becoming done.
After the grace period, the block is forced done.
Diffstat (limited to 'lib/input_handlers.cpp')
-rw-r--r-- | lib/input_handlers.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/input_handlers.cpp b/lib/input_handlers.cpp index 89e1d34..3027257 100644 --- a/lib/input_handlers.cpp +++ b/lib/input_handlers.cpp @@ -63,6 +63,12 @@ void BlockActor::handle_input_check(const InputCheckMessage &message, const Ther MESSAGE_TRACER(); const size_t index = message.index; + //record time of the first input declared done + if (not data->inputs_done.any()) + { + data->first_input_done_time = boost::get_system_time(); + } + //an upstream block declared itself done, recheck the token data->inputs_done.set(index, data->input_tokens[index].unique()); @@ -70,8 +76,15 @@ void BlockActor::handle_input_check(const InputCheckMessage &message, const Ther ta.done(); this->task_main(); - //now recheck the status, mark block done if the input is done - if (this->is_input_done(index)) this->mark_done(); + //Now check the status, mark block done if the input is done: + //When reserve_items is non zero, this ports is a sync input; + //mark the block done if the sync input will never be ready again. + //Otherwise, only mark done if all inputs are done with no data. + const size_t reserve_items = data->input_configs[index].reserve_items; + if ( + (reserve_items != 0 and data->inputs_done[index] and not data->inputs_available[index]) + or (reserve_items == 0 and data->inputs_done.all() and data->inputs_available.none()) + ) this->mark_done(); } void BlockActor::handle_input_alloc(const InputAllocMessage &message, const Theron::Address) |