summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh Blum2012-09-22 17:49:52 -0400
committerJosh Blum2012-09-22 17:49:52 -0400
commita76963ab6fdde4bf793ecb38f95fa6255647288a (patch)
tree9dc44a50a830f7d3d76ea11f7cac9ae4aef558b0
parent89de2759ba95682f51865dd06b7509e48969dc96 (diff)
downloadsandhi-a76963ab6fdde4bf793ecb38f95fa6255647288a.tar.gz
sandhi-a76963ab6fdde4bf793ecb38f95fa6255647288a.tar.bz2
sandhi-a76963ab6fdde4bf793ecb38f95fa6255647288a.zip
threading related tweaks for happy qa code
m---------gnuradio0
-rw-r--r--lib/block_handlers.cpp4
-rw-r--r--lib/block_task.cpp2
-rw-r--r--lib/gras_impl/interruptible_thread.hpp6
-rw-r--r--lib/top_block.cpp14
5 files changed, 22 insertions, 4 deletions
diff --git a/gnuradio b/gnuradio
-Subproject 5d3e66f719a161fc651b5b0740560d2a95fb982
+Subproject 86a4cd379100a2167cf402de80826762210450e
diff --git a/lib/block_handlers.cpp b/lib/block_handlers.cpp
index a3a42b6..384deaa 100644
--- a/lib/block_handlers.cpp
+++ b/lib/block_handlers.cpp
@@ -85,6 +85,10 @@ void ElementImpl::handle_block_msg(
ASSERT(msg.type() == typeid(TopBlockMessage));
+ //FIXME leave the marked done blocks done...
+ //this helps QA tests to pass that re-use top block without diconnecting the old design
+ if (this->block_state == BLOCK_STATE_DONE) return;
+
const size_t num_inputs = task_iface.get_num_inputs();
const size_t num_outputs = task_iface.get_num_outputs();
diff --git a/lib/block_task.cpp b/lib/block_task.cpp
index f6f3dcb..6329ab0 100644
--- a/lib/block_task.cpp
+++ b/lib/block_task.cpp
@@ -196,7 +196,7 @@ void ElementImpl::handle_task(const tsbe::TaskInterface &task_iface)
//-- the work
//------------------------------------------------------------------
work_noutput_items = num_output_items;
- /*if (this->enable_fixed_rate)*/ work_noutput_items = std::min(
+ if (this->enable_fixed_rate) work_noutput_items = std::min(
work_noutput_items, myulround((num_input_items)*this->relative_rate));
this->work_task_iface = task_iface;
this->work_ret = -1;
diff --git a/lib/gras_impl/interruptible_thread.hpp b/lib/gras_impl/interruptible_thread.hpp
index 7546019..9ac7349 100644
--- a/lib/gras_impl/interruptible_thread.hpp
+++ b/lib/gras_impl/interruptible_thread.hpp
@@ -69,6 +69,12 @@ namespace gnuradio
}
_thread->interrupt();
_thread->join();
+
+ //We dont need to manually remove and delete the thread,
+ //but I thought it was nicer than thread group accumulating
+ //dead threads run after run.
+ _thread_group->remove_thread(_thread);
+ delete _thread;
}
GRAS_FORCE_INLINE void call(void)
diff --git a/lib/top_block.cpp b/lib/top_block.cpp
index bea7371..fdabad1 100644
--- a/lib/top_block.cpp
+++ b/lib/top_block.cpp
@@ -106,16 +106,24 @@ void TopBlock::run(void)
this->wait();
}
+GRAS_FORCE_INLINE void wait_thread_yield(void)
+{
+ //boost::this_thread::yield();
+ boost::this_thread::sleep(boost::posix_time::milliseconds(1));
+}
+
void TopBlock::wait(void)
{
//We do not need to join "special" threads;
//the token mechainism will do just fine.
- (*this)->thread_group->join_all();
+ //FIXME it might be nice to uncomment this for some nice quiet wait(),
+ //however, thread group cant be joined twice and this breaks some qa code
+ //(*this)->thread_group->join_all();
//wait for all blocks to release the token
while (not (*this)->token.unique())
{
- boost::this_thread::yield();
+ wait_thread_yield();
}
}
@@ -127,7 +135,7 @@ bool TopBlock::wait(const double timeout)
//wait for all blocks to release the token
while (not (*this)->token.unique() or boost::get_system_time() < exit_time)
{
- boost::this_thread::yield();
+ wait_thread_yield();
}
return (*this)->token.unique();