[beast: 35/95] BSE: eliminate ThreadInfo & ThreadState, register threads with TaskRegistry
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast: 35/95] BSE: eliminate ThreadInfo & ThreadState, register threads with TaskRegistry
- Date: Mon, 25 Mar 2013 00:39:27 +0000 (UTC)
commit da50ff195e3453f2bc152ccbe0f5d405cf96e187
Author: Tim Janik <timj gnu org>
Date: Mon Mar 18 21:24:12 2013 +0100
BSE: eliminate ThreadInfo & ThreadState, register threads with TaskRegistry
bse/bsebasics.idl | 39 ----------------------------
bse/bseengine.cc | 4 +++
bse/bseenginemaster.cc | 2 +
bse/bsemain.cc | 5 ++-
bse/bsemain.hh | 6 +++-
bse/bseprobe.cc | 65 ++---------------------------------------------
bse/bseprobe.idl | 4 +--
bse/bseresampler.hh | 2 +
bse/bsesequencer.cc | 2 +
9 files changed, 21 insertions(+), 108 deletions(-)
---
diff --git a/bse/bsebasics.idl b/bse/bsebasics.idl
index f4f2ab4..c03ea69 100644
--- a/bse/bsebasics.idl
+++ b/bse/bsebasics.idl
@@ -671,45 +671,6 @@ record Message {
String process;
Int pid;
};
-/* thread info */
-enum ThreadState {
- THREAD_STATE_UNKNOWN,
- THREAD_STATE_RUNNING,
- THREAD_STATE_SLEEPING,
- THREAD_STATE_DISKWAIT,
- THREAD_STATE_TRACED,
- THREAD_STATE_PAGING,
- THREAD_STATE_ZOMBIE,
- THREAD_STATE_DEAD,
-};
-record ThreadInfo {
- String name = SfiString (_("Thread Name"), "", "", STANDARD);
- ThreadState state = SfiEnum (_("State"), _("The execution state of the thread"), THREAD_STATE_UNKNOWN,
STANDARD);
- Int thread_id = SfiInt (_("Thread ID"), _("A unique number identifying this thread"),
- 0, 0, G_MAXINT, 1, STANDARD);
- Int priority = SfiInt (_("Priority"), _("The nice value of a thread, -20 indicates a high
priority thread and "
- "+19 a low priority one that is 'nice' to others"),
- 0, -20, 19, 1, STANDARD);
- Int processor = SfiInt (_("Processor"), _("The processor that this thread is currently being
executed on"),
- 0, 0, MAXINT, 1, STANDARD);
- Int utime = SfiInt (_("User Time"), _("The CPU time spent executing instructions of this
thread"),
- 0, 0, MAXINT, 1, STANDARD);
- Int stime = SfiInt (_("System Time"), _("The CPU time spent in the system for this thread"),
- 0, 0, MAXINT, 1, STANDARD);
- Int cutime = SfiInt (_("Child User Time"), _("The CPU time spent executing instructions of
children of this thread"),
- 0, 0, MAXINT, 1, STANDARD);
- Int cstime = SfiInt (_("Child System Time"), _("The CPU time spent in the system for children
of this thread"),
- 0, 0, MAXINT, 1, STANDARD);
-};
-sequence ThreadInfoSeq {
- ThreadInfo thread_infos;
-};
-record ThreadTotals {
- ThreadInfo main;
- ThreadInfo sequencer;
- ThreadInfoSeq synthesis;
-};
-// 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/bseengine.cc b/bse/bseengine.cc
index 0084f52..91366a0 100644
--- a/bse/bseengine.cc
+++ b/bse/bseengine.cc
@@ -1,11 +1,13 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bseengine.hh"
+#include "bsecore.hh"
#include "gslcommon.hh"
#include "bseengineutils.hh"
#include "bseenginemaster.hh"
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
+
static SFI_MSG_TYPE_DEFINE (debug_engine, "engine", SFI_MSG_DEBUG, NULL);
#define DEBUG(...) sfi_debug (debug_engine, __VA_ARGS__)
/* some systems don't have ERESTART (which is what linux returns for system
@@ -1074,6 +1076,7 @@ bse_module_new_virtual (guint n_iostreams,
static void
slave (gpointer data)
{
+ Bse::TaskRegistry::add ("DSP Slave", Rapicorn::ThisThread::process_pid(),
Rapicorn::ThisThread::thread_pid());
gboolean run = TRUE;
while (run)
{
@@ -1088,6 +1091,7 @@ slave (gpointer data)
bse_trans_commit (trans);
g_usleep (1000*500);
}
+ Bse::TaskRegistry::remove (Rapicorn::ThisThread::thread_pid());
}
/* --- setup & trigger --- */
static gboolean bse_engine_initialized = FALSE;
diff --git a/bse/bseenginemaster.cc b/bse/bseenginemaster.cc
index c2f4abf..917123d 100644
--- a/bse/bseenginemaster.cc
+++ b/bse/bseenginemaster.cc
@@ -1043,6 +1043,7 @@ _engine_master_dispatch (void)
void
bse_engine_master_thread (EngineMasterData *mdata)
{
+ Bse::TaskRegistry::add ("DSP #1", Rapicorn::ThisThread::process_pid(), Rapicorn::ThisThread::thread_pid());
bse_message_setup_thread_handler ();
/* assert pollfd equality, since we're simply casting structures */
BIRNET_STATIC_ASSERT (sizeof (struct pollfd) == sizeof (GPollFD));
@@ -1089,5 +1090,6 @@ bse_engine_master_thread (EngineMasterData *mdata)
if (bse_engine_has_garbage ())
sfi_thread_wakeup (mdata->user_thread);
}
+ Bse::TaskRegistry::remove (Rapicorn::ThisThread::thread_pid());
}
/* vim:set ts=8 sts=2 sw=2: */
diff --git a/bse/bsemain.cc b/bse/bsemain.cc
index 110c672..6e72337 100644
--- a/bse/bsemain.cc
+++ b/bse/bsemain.cc
@@ -1,5 +1,6 @@
// Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
#include "bsemain.hh"
+#include "bsecore.hh"
#include "topconfig.h"
#include "bseserver.hh"
#include "bsesequencer.hh"
@@ -35,7 +36,6 @@ const guint bse_binary_age = BSE_BINARY_AGE;
const gchar *bse_version = BSE_VERSION;
GMainContext *bse_main_context = NULL;
BirnetMutex bse_main_sequencer_mutex = { 0, };
-BirnetThread *bse_main_thread = NULL;
static volatile gboolean bse_initialization_stage = 0;
static gboolean textdomain_setup = FALSE;
static BseMainArgs default_main_args = {
@@ -331,7 +331,7 @@ bse_init_test (gint *argc,
static void
bse_main_loop (Rapicorn::AsyncBlockingQueue<int> *init_queue)
{
- bse_main_thread = sfi_thread_self ();
+ Bse::TaskRegistry::add ("BSE Core", Rapicorn::ThisThread::process_pid(),
Rapicorn::ThisThread::thread_pid());
bse_init_core ();
// start other threads
bse_sequencer_init_thread ();
@@ -346,6 +346,7 @@ bse_main_loop (Rapicorn::AsyncBlockingQueue<int> *init_queue)
g_main_context_iteration (bse_main_context, TRUE);
}
while (!sfi_thread_aborted ());
+ Bse::TaskRegistry::remove (Rapicorn::ThisThread::thread_pid());
}
guint
bse_main_getpid (void)
diff --git a/bse/bsemain.hh b/bse/bsemain.hh
index 37a0757..2a20be0 100644
--- a/bse/bsemain.hh
+++ b/bse/bsemain.hh
@@ -16,7 +16,6 @@ const char* bse_check_version (guint required_major,
guint required_minor,
guint required_micro); // prototyped in bse.hh
-
/* initialization for internal utilities */
void bse_init_inprocess (gint *argc,
gchar ***argv,
@@ -69,16 +68,19 @@ typedef struct {
SfiRing *pcm_drivers;
SfiRing *midi_drivers;
} BseMainArgs;
+
/* --- debuging channels --- */
typedef struct {
SfiDebugChannel *sequencer; /* --bse-trace-sequencer */
} BseTraceArgs;
+
/* --- internal --- */
void _bse_init_c_wrappers ();
extern BseMainArgs *bse_main_args;
extern BseTraceArgs bse_trace_args;
extern GMainContext *bse_main_context;
extern BirnetMutex bse_main_sequencer_mutex;
-extern BirnetThread *bse_main_thread;
+
G_END_DECLS
+
#endif /* __BSE_MAIN_H__ */
diff --git a/bse/bseprobe.cc b/bse/bseprobe.cc
index 112d0dc..4c65018 100644
--- a/bse/bseprobe.cc
+++ b/bse/bseprobe.cc
@@ -697,67 +697,6 @@ source_get_mix_freq::exec (BseSource *self)
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();
@@ -766,6 +705,7 @@ BSE_CXX_REGISTER_ALL_TYPES_FROM_BSEPROBE_IDL();
/* --- bsesource.hh bits --- */
extern "C" { // from bsesource.hh
using namespace Bse;
+
void
bse_source_clear_probes (BseSource *source)
{
@@ -773,7 +713,8 @@ bse_source_clear_probes (BseSource *source)
SourceProbes *probes = SourceProbes::peek_from_source (source);
source->probes = NULL;
delete probes;
-}
+}
+
void
bse_source_probes_modules_changed (BseSource *source)
{
diff --git a/bse/bseprobe.idl b/bse/bseprobe.idl
index 8e75267..42c3ee3 100644
--- a/bse/bseprobe.idl
+++ b/bse/bseprobe.idl
@@ -2,7 +2,7 @@
include "bsecxxmodule.idl";
namespace Bse {
- record ProbeFeatures {
+record ProbeFeatures {
Bool probe_range;
Bool probe_energie;
Bool probe_samples;
@@ -39,6 +39,4 @@ 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: bsebasics.idl
-
};
diff --git a/bse/bseresampler.hh b/bse/bseresampler.hh
index 23dcb02..7687607 100644
--- a/bse/bseresampler.hh
+++ b/bse/bseresampler.hh
@@ -34,6 +34,8 @@ G_END_DECLS
#ifdef __cplusplus
#include <vector>
namespace Bse {
+
+/// The Resampler namespace contains interfaces for factor 2 resampling.
namespace Resampler {
/**
* Interface for factor 2 resampling classes
diff --git a/bse/bsesequencer.cc b/bse/bsesequencer.cc
index e1ca94f..9719aeb 100644
--- a/bse/bsesequencer.cc
+++ b/bse/bsesequencer.cc
@@ -367,6 +367,7 @@ bse_sequencer_thread_lagging (guint n_blocks)
static void
bse_sequencer_thread_main (gpointer data)
{
+ Bse::TaskRegistry::add ("Sequencer", Rapicorn::ThisThread::process_pid(),
Rapicorn::ThisThread::thread_pid());
SEQTRACE ("SEQ:thrdstrt: now=%llu", Bse::TickStamp::current());
Bse::TickStampWakeupP wakeup = Bse::TickStamp::create_wakeup (bse_sequencer_wakeup);
bse_message_setup_thread_handler();
@@ -423,6 +424,7 @@ bse_sequencer_thread_main (gpointer data)
while (bse_sequencer_poll_Lm (-1));
BSE_SEQUENCER_UNLOCK ();
SEQTRACE ("SEQ:thrdstop: now=%llu", Bse::TickStamp::current());
+ Bse::TaskRegistry::remove (Rapicorn::ThisThread::thread_pid());
}
static void
bse_sequencer_process_track_SL (BseTrack *track,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]