commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r8817 - gnuradio/branches/developers/eb/sched-wip/gnur


From: eb
Subject: [Commit-gnuradio] r8817 - gnuradio/branches/developers/eb/sched-wip/gnuradio-core/src/lib/runtime
Date: Mon, 7 Jul 2008 15:34:57 -0600 (MDT)

Author: eb
Date: 2008-07-07 15:34:56 -0600 (Mon, 07 Jul 2008)
New Revision: 8817

Modified:
   
gnuradio/branches/developers/eb/sched-wip/gnuradio-core/src/lib/runtime/gr_block_executor.cc
   
gnuradio/branches/developers/eb/sched-wip/gnuradio-core/src/lib/runtime/gr_top_block_impl.cc
Log:
allow scheduler to be selected at runtime

Modified: 
gnuradio/branches/developers/eb/sched-wip/gnuradio-core/src/lib/runtime/gr_block_executor.cc
===================================================================
--- 
gnuradio/branches/developers/eb/sched-wip/gnuradio-core/src/lib/runtime/gr_block_executor.cc
        2008-07-07 21:22:11 UTC (rev 8816)
+++ 
gnuradio/branches/developers/eb/sched-wip/gnuradio-core/src/lib/runtime/gr_block_executor.cc
        2008-07-07 21:34:56 UTC (rev 8817)
@@ -35,7 +35,7 @@
 #include <stdio.h>
 
 // must be defined to either 0 or 1
-#define ENABLE_LOGGING 1
+#define ENABLE_LOGGING 0
 
 #if (ENABLE_LOGGING)
 #define LOG(x) do { x; } while(0)

Modified: 
gnuradio/branches/developers/eb/sched-wip/gnuradio-core/src/lib/runtime/gr_top_block_impl.cc
===================================================================
--- 
gnuradio/branches/developers/eb/sched-wip/gnuradio-core/src/lib/runtime/gr_top_block_impl.cc
        2008-07-07 21:22:11 UTC (rev 8816)
+++ 
gnuradio/branches/developers/eb/sched-wip/gnuradio-core/src/lib/runtime/gr_top_block_impl.cc
        2008-07-07 21:34:56 UTC (rev 8817)
@@ -34,23 +34,45 @@
 #include <iostream>
 #include <string.h>
 #include <unistd.h>
+#include <stdlib.h>
 
 #define GR_TOP_BLOCK_IMPL_DEBUG 0
 
 
-#define USE_STS        0
-#define        USE_TPB 1
+typedef gr_scheduler_sptr (*scheduler_maker)(gr_flat_flowgraph_sptr ffg);
 
+static struct scheduler_table {
+  const char          *name;
+  scheduler_maker      f;
+} scheduler_table[] = {
+  { "STS",     gr_scheduler_sts::make },       // first entry is default
+  { "TPB",     gr_scheduler_tpb::make }
+};
 
 static gr_scheduler_sptr
 make_scheduler(gr_flat_flowgraph_sptr ffg)
 {
-#if (USE_STS)
-  return gr_scheduler_sts::make(ffg);
-#endif
-#if (USE_TPB)
-  return gr_scheduler_tpb::make(ffg);
-#endif
+  static scheduler_maker  factory = 0;
+
+  if (factory == 0){
+    char *v = getenv("GR_SCHEDULER");
+    if (!v)
+      factory = scheduler_table[0].f;  // use default
+    else {
+      for (size_t i = 0; i < 
sizeof(scheduler_table)/sizeof(scheduler_table[0]); i++){
+       if (strcmp(v, scheduler_table[i].name) == 0){
+         factory = scheduler_table[i].f;
+         break;
+       }
+      }
+      if (factory == 0){
+       std::cerr << "warning: Invalid GR_SCHEDULER environment variable value 
\""
+                 << v << "\".  Using \"" << scheduler_table[0].name << "\"\n";
+       factory = scheduler_table[0].f;
+      }
+    }
+  }
+  return factory(ffg);
 }
 
 





reply via email to

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