commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r3878 - gnuradio/branches/developers/trondeau/flowgrap


From: trondeau
Subject: [Commit-gnuradio] r3878 - gnuradio/branches/developers/trondeau/flowgraph_test/gnuradio-core/src/lib/runtime
Date: Fri, 27 Oct 2006 14:26:55 -0600 (MDT)

Author: trondeau
Date: 2006-10-27 14:26:54 -0600 (Fri, 27 Oct 2006)
New Revision: 3878

Modified:
   
gnuradio/branches/developers/trondeau/flowgraph_test/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.cc
   
gnuradio/branches/developers/trondeau/flowgraph_test/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.h
   
gnuradio/branches/developers/trondeau/flowgraph_test/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.i
Log:
added pause/unpause capability to flow graph

Modified: 
gnuradio/branches/developers/trondeau/flowgraph_test/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.cc
===================================================================
--- 
gnuradio/branches/developers/trondeau/flowgraph_test/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.cc
  2006-10-27 19:50:43 UTC (rev 3877)
+++ 
gnuradio/branches/developers/trondeau/flowgraph_test/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.cc
  2006-10-27 20:26:54 UTC (rev 3878)
@@ -71,6 +71,8 @@
           << d_blocks.size ()
           << " blocks\n";
   }
+
+  sem_init(&d_sem, 0, 1);
 }
 
 gr_single_threaded_scheduler::~gr_single_threaded_scheduler ()
@@ -86,7 +88,25 @@
   main_loop ();
 }
 
+void
+gr_single_threaded_scheduler::pause() 
+{ 
+  d_pause = true; 
+}
 
+void
+gr_single_threaded_scheduler::unpause()
+{ 
+  d_pause = false; 
+  sem_post(&d_sem); 
+}
+
+bool
+gr_single_threaded_scheduler::is_paused()
+{ 
+  return d_pause; 
+}
+
 inline static unsigned int
 round_up (unsigned int n, unsigned int multiple)
 {
@@ -154,6 +174,10 @@
   nalive = d_blocks.size ();
   while (d_enabled && nalive > 0){
 
+    sem_wait(&d_sem);
+    if(!d_pause)
+      sem_post(&d_sem);
+
     gr_block           *m = d_blocks[bi].get ();
     gr_block_detail    *d = m->detail().get ();
 

Modified: 
gnuradio/branches/developers/trondeau/flowgraph_test/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.h
===================================================================
--- 
gnuradio/branches/developers/trondeau/flowgraph_test/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.h
   2006-10-27 19:50:43 UTC (rev 3877)
+++ 
gnuradio/branches/developers/trondeau/flowgraph_test/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.h
   2006-10-27 20:26:54 UTC (rev 3878)
@@ -25,6 +25,7 @@
 
 #include <gr_runtime.h>
 #include <fstream>
+#include <semaphore.h>
 
 class gr_single_threaded_scheduler;
 typedef boost::shared_ptr<gr_single_threaded_scheduler>        
gr_single_threaded_scheduler_sptr;
@@ -40,11 +41,16 @@
   ~gr_single_threaded_scheduler ();
 
   void run ();
-  void stop () { d_enabled = false; }
+  void stop () { d_enabled = false; unpause(); }
+  void pause();
+  void unpause();
+  bool is_paused();
 
  private:
   const std::vector<gr_block_sptr>     d_blocks;
   volatile bool                                d_enabled;
+  bool                                  d_pause;
+  sem_t                                 d_sem;
   std::ofstream                               *d_log;
 
   gr_single_threaded_scheduler (const std::vector<gr_block_sptr> &blocks);

Modified: 
gnuradio/branches/developers/trondeau/flowgraph_test/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.i
===================================================================
--- 
gnuradio/branches/developers/trondeau/flowgraph_test/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.i
   2006-10-27 19:50:43 UTC (rev 3877)
+++ 
gnuradio/branches/developers/trondeau/flowgraph_test/gnuradio-core/src/lib/runtime/gr_single_threaded_scheduler.i
   2006-10-27 20:26:54 UTC (rev 3878)
@@ -37,6 +37,9 @@
 
   // void run ();
   void stop ();
+  void pause();
+  void unpause();
+  bool is_paused();
 
  private:
   gr_single_threaded_scheduler (const std::vector<gr_block_sptr> &modules);





reply via email to

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