[beast/devel: 15/16] BSE: move collect_thread_totals() to keep procedures out of bsecore.idl



commit a680f4a5d801ff32eeaa23a41b85d944419ea3aa
Author: Tim Janik <timj gnu org>
Date:   Fri Jan 4 01:57:49 2013 +0100

    BSE: move collect_thread_totals() to keep procedures out of bsecore.idl

 bse/bsecore.cc   |   65 ------------------------------------------------------
 bse/bsecore.idl  |    2 +-
 bse/bseprobe.cc  |   64 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 bse/bseprobe.idl |    3 ++
 4 files changed, 68 insertions(+), 66 deletions(-)
---
diff --git a/bse/bsecore.cc b/bse/bsecore.cc
index 41901f8..9c47f87 100644
--- a/bse/bsecore.cc
+++ b/bse/bsecore.cc
@@ -1,73 +1,8 @@
 // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
 #include "bsetype.hh"        /* import all required types first */
-#include "bsepart.hh"
 #include "bsemain.hh"
-#include "bseengine.hh"
-#include "bsesequencer.hh"
 #include "bsecxxplugin.hh" /* includes bsecore.genidl.hh for us */
 namespace Bse {
-namespace Procedure {
-ThreadTotalsHandle
-collect_thread_totals::exec ()
-{
-  struct Sub {
-    static ThreadState convert (BirnetThreadState ts)
-    {
-      switch (ts)
-        {
-        default:
-        case BIRNET_THREAD_UNKNOWN:     return THREAD_STATE_UNKNOWN;
-        case BIRNET_THREAD_RUNNING:     return THREAD_STATE_RUNNING;
-        case BIRNET_THREAD_SLEEPING:    return THREAD_STATE_SLEEPING;
-        case BIRNET_THREAD_DISKWAIT:    return THREAD_STATE_DISKWAIT;
-        case BIRNET_THREAD_TRACED:      return THREAD_STATE_TRACED;
-        case BIRNET_THREAD_PAGING:      return THREAD_STATE_PAGING;
-        case BIRNET_THREAD_ZOMBIE:      return THREAD_STATE_ZOMBIE;
-        case BIRNET_THREAD_DEAD:        return THREAD_STATE_DEAD;
-        }
-    }
-    static void assign (ThreadInfoHandle &th,
-                        BirnetThreadInfo    *ti)
-    {
-      th->name = ti->name;
-      th->thread_id = ti->thread_id;
-      th->state = convert (ti->state);
-      th->priority = ti->priority;
-      th->processor = ti->processor;
-      th->utime = ti->utime;
-      th->stime = ti->stime;
-      th->cutime = ti->cutime;
-      th->cstime = ti->cstime;
-    }
-  };
-  ThreadTotalsHandle tth (Sfi::INIT_DEFAULT);
-  BirnetThreadInfo *ti;
-  ti = sfi_thread_info_collect (bse_main_thread);
-  tth->main = ThreadInfoHandle (Sfi::INIT_DEFAULT);
-  Sub::assign (tth->main, ti);
-  sfi_thread_info_free (ti);
-  if (bse_sequencer_thread)
-    {
-      ti = sfi_thread_info_collect (bse_sequencer_thread);
-      tth->sequencer = ThreadInfoHandle (Sfi::INIT_DEFAULT);
-      Sub::assign (tth->sequencer, ti);
-      sfi_thread_info_free (ti);
-    }
-  guint n;
-  BirnetThread **t;
-  t = bse_engine_get_threads (&n);
-  for (guint i = 0; i < n; i++)
-    {
-      ti = sfi_thread_info_collect (t[i]);
-      tth->synthesis.resize (i + 1);
-      tth->synthesis[i] = ThreadInfoHandle (Sfi::INIT_DEFAULT);
-      Sub::assign (tth->synthesis[i], ti);
-      sfi_thread_info_free (ti);
-    }
-  g_free (t);
-  return tth;
-}
-} // Procedure
 /* export definitions follow */
 BSE_CXX_DEFINE_EXPORTS();
 BSE_CXX_REGISTER_ALL_TYPES_FROM_BSECORE_IDL();
diff --git a/bse/bsecore.idl b/bse/bsecore.idl
index 19f3c45..f4f2ab4 100644
--- a/bse/bsecore.idl
+++ b/bse/bsecore.idl
@@ -709,7 +709,7 @@ record ThreadTotals {
   ThreadInfo    sequencer;
   ThreadInfoSeq synthesis;
 };
-ThreadTotals    collect_thread_totals ();
+// bseprobe.idl: ThreadTotals collect_thread_totals ();
 
 // == BSE Global Config ==
 Const DEFAULT_AUTHOR  = "\357\277\271\357\277\272{{bse.idl/default-author}}\357\277\273";
diff --git a/bse/bseprobe.cc b/bse/bseprobe.cc
index 5a3557b..bdcc4af 100644
--- a/bse/bseprobe.cc
+++ b/bse/bseprobe.cc
@@ -4,6 +4,8 @@
 #include "bseblockutils.hh"
 #include "gslcommon.hh" /* for gsl_tick_stamp() */
 #include "gslfft.hh"
+#include "bsemain.hh"
+#include "bsesequencer.hh"
 #include <stdexcept>
 #include <set>
 using namespace std;
@@ -694,6 +696,68 @@ source_get_mix_freq::exec (BseSource *self)
     throw std::runtime_error ("invalid arguments");
   return BSE_SOURCE_PREPARED (self) ? bse_engine_sample_freq() : 0;
 }
+
+ThreadTotalsHandle
+collect_thread_totals::exec ()
+{
+  struct Sub {
+    static ThreadState convert (BirnetThreadState ts)
+    {
+      switch (ts)
+        {
+        default:
+        case BIRNET_THREAD_UNKNOWN:     return THREAD_STATE_UNKNOWN;
+        case BIRNET_THREAD_RUNNING:     return THREAD_STATE_RUNNING;
+        case BIRNET_THREAD_SLEEPING:    return THREAD_STATE_SLEEPING;
+        case BIRNET_THREAD_DISKWAIT:    return THREAD_STATE_DISKWAIT;
+        case BIRNET_THREAD_TRACED:      return THREAD_STATE_TRACED;
+        case BIRNET_THREAD_PAGING:      return THREAD_STATE_PAGING;
+        case BIRNET_THREAD_ZOMBIE:      return THREAD_STATE_ZOMBIE;
+        case BIRNET_THREAD_DEAD:        return THREAD_STATE_DEAD;
+        }
+    }
+    static void assign (ThreadInfoHandle &th,
+                        BirnetThreadInfo    *ti)
+    {
+      th->name = ti->name;
+      th->thread_id = ti->thread_id;
+      th->state = convert (ti->state);
+      th->priority = ti->priority;
+      th->processor = ti->processor;
+      th->utime = ti->utime;
+      th->stime = ti->stime;
+      th->cutime = ti->cutime;
+      th->cstime = ti->cstime;
+    }
+  };
+  ThreadTotalsHandle tth (Sfi::INIT_DEFAULT);
+  BirnetThreadInfo *ti;
+  ti = sfi_thread_info_collect (bse_main_thread);
+  tth->main = ThreadInfoHandle (Sfi::INIT_DEFAULT);
+  Sub::assign (tth->main, ti);
+  sfi_thread_info_free (ti);
+  if (bse_sequencer_thread)
+    {
+      ti = sfi_thread_info_collect (bse_sequencer_thread);
+      tth->sequencer = ThreadInfoHandle (Sfi::INIT_DEFAULT);
+      Sub::assign (tth->sequencer, ti);
+      sfi_thread_info_free (ti);
+    }
+  guint n;
+  BirnetThread **t;
+  t = bse_engine_get_threads (&n);
+  for (guint i = 0; i < n; i++)
+    {
+      ti = sfi_thread_info_collect (t[i]);
+      tth->synthesis.resize (i + 1);
+      tth->synthesis[i] = ThreadInfoHandle (Sfi::INIT_DEFAULT);
+      Sub::assign (tth->synthesis[i], ti);
+      sfi_thread_info_free (ti);
+    }
+  g_free (t);
+  return tth;
+}
+
 } // Procedure
 /* export definitions follow */
 BSE_CXX_DEFINE_EXPORTS();
diff --git a/bse/bseprobe.idl b/bse/bseprobe.idl
index 8afe3cb..c597890 100644
--- a/bse/bseprobe.idl
+++ b/bse/bseprobe.idl
@@ -38,4 +38,7 @@ void source_request_probes (Source          source,
 void source_mass_request   (ProbeRequestSeq prseq);
 Num  source_get_tick_stamp (Source          obj);
 Int  source_get_mix_freq   (Source          obj);
+
+ThreadTotals collect_thread_totals (); // from: bsecore.idl
+
 };



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