summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-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
4 files changed, 22 insertions, 4 deletions
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();