commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 11/18: runtime: scheduler: no busy-waiting


From: git
Subject: [Commit-gnuradio] [gnuradio] 11/18: runtime: scheduler: no busy-waiting
Date: Fri, 1 Jul 2016 16:25:45 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch next
in repository gnuradio.

commit 333670c67f8ef683b66b3fe247c3750a460cac59
Author: Bastian Bloessl <address@hidden>
Date:   Mon May 2 12:49:29 2016 +0200

    runtime: scheduler: no busy-waiting
---
 gnuradio-runtime/include/gnuradio/tpb_detail.h |  3 +++
 gnuradio-runtime/lib/tpb_thread_body.cc        | 28 ++------------------------
 2 files changed, 5 insertions(+), 26 deletions(-)

diff --git a/gnuradio-runtime/include/gnuradio/tpb_detail.h 
b/gnuradio-runtime/include/gnuradio/tpb_detail.h
index 9b7454b..4e66014 100644
--- a/gnuradio-runtime/include/gnuradio/tpb_detail.h
+++ b/gnuradio-runtime/include/gnuradio/tpb_detail.h
@@ -58,7 +58,10 @@ namespace gr {
 
     //! Called by pmt msg posters
     void notify_msg() {
+      gr::thread::scoped_lock guard(mutex);
+      input_changed = true;
       input_cond.notify_one();
+      output_changed = true;
       output_cond.notify_one();
     }
 
diff --git a/gnuradio-runtime/lib/tpb_thread_body.cc 
b/gnuradio-runtime/lib/tpb_thread_body.cc
index 1f98454..d49c088 100644
--- a/gnuradio-runtime/lib/tpb_thread_body.cc
+++ b/gnuradio-runtime/lib/tpb_thread_body.cc
@@ -93,7 +93,6 @@ namespace gr {
     block->clear_finished();
 
     while(1) {
-      tpb_loop_top:
       boost::this_thread::interruption_point();
 
       // handle any queued up messages
@@ -156,32 +155,9 @@ namespace gr {
       {
         gr::thread::scoped_lock guard(d->d_tpb.mutex);
         while(!d->d_tpb.input_changed) {
-
           // wait for input or message
-          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 occurred (perform sanity checks up 
top)
-            }
-          }
-
-          // handle all pending messages
-          BOOST_FOREACH(basic_block::msg_queue_map_t::value_type &i, 
block->msg_queue) {
-            if(block->has_msg_handler(i.first)) {
-              while((msg = block->delete_head_nowait(i.first))) {
-                guard.unlock();                        // release lock while 
processing msg
-                block->dispatch_msg(i.first, msg);
-                guard.lock();
-              }
-            }
-            else {
-              // leave msg in queue if no handler is defined
-              // start dropping if we have too many
-              if(block->nmsgs(i.first) > max_nmsgs){
-                GR_LOG_WARN(LOG,"asynchronous message buffer overflowing, 
dropping message");
-                msg = block->delete_head_nowait(i.first);
-              }
-            }
+          if(!d->d_tpb.input_changed && block->empty_handled_p()) {
+            d->d_tpb.input_cond.wait(guard);
           }
         }
       }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]