diff options
author | Tim O'Shea <tim.oshea753@gmail.com> | 2014-04-23 21:33:15 -0400 |
---|---|---|
committer | Tim O'Shea <tim.oshea753@gmail.com> | 2014-04-23 21:33:15 -0400 |
commit | 93494c1c17d6751e94fa8a1a5479d2c701750baf (patch) | |
tree | 73123830b2bb916526d3feda669b961e21b3cd03 /gnuradio-runtime/lib/tpb_thread_body.cc | |
parent | 3831dd37c8df19e25fa258db4d393ee068889dae (diff) |
runtime: fix propagation of DONE state to message blocks
Diffstat (limited to 'gnuradio-runtime/lib/tpb_thread_body.cc')
-rw-r--r-- | gnuradio-runtime/lib/tpb_thread_body.cc | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/gnuradio-runtime/lib/tpb_thread_body.cc b/gnuradio-runtime/lib/tpb_thread_body.cc index 79abd0e61d..eb47a43ee3 100644 --- a/gnuradio-runtime/lib/tpb_thread_body.cc +++ b/gnuradio-runtime/lib/tpb_thread_body.cc @@ -83,8 +83,12 @@ namespace gr { if(block->thread_priority() > 0) { gr::thread::set_thread_priority(d->thread, block->thread_priority()); } + + // make sure our block isnt finished + block->clear_finished(); while(1) { + tpb_loop_top: boost::this_thread::interruption_point(); // handle any queued up messages @@ -116,6 +120,10 @@ namespace gr { s = block_executor::BLKD_IN; } + // if msg ports think we are done, we are done + if(block->finished()) + s = block_executor::DONE; + switch(s){ case block_executor::READY: // Tell neighbors we made progress. d->d_tpb.notify_neighbors(d); @@ -126,6 +134,7 @@ namespace gr { break; case block_executor::DONE: // Game over. + block->notify_msg_neighbors(); d->d_tpb.notify_neighbors(d); return; @@ -135,8 +144,12 @@ namespace gr { while(!d->d_tpb.input_changed) { // wait for input or message - while(!d->d_tpb.input_changed && block->empty_handled_p()) - d->d_tpb.input_cond.wait(guard); + while(!d->d_tpb.input_changed && block->empty_handled_p()){ + boost::system_time const timeout=boost::get_system_time()+ boost::posix_time::milliseconds(250); + if(!d->d_tpb.input_cond.timed_wait(guard, timeout)){ + goto tpb_loop_top; // timeout occured (perform sanity checks up top) + } + } // handle all pending messages BOOST_FOREACH(basic_block::msg_queue_map_t::value_type &i, block->msg_queue) { |