[beast: 8/20] BSE: use this_thread_*() for name/getpid/gettid/online_cpus



commit 868d3468b843dc1064aefda0641529af8af48cba
Author: Tim Janik <timj gnu org>
Date:   Sun Sep 17 03:01:48 2017 +0200

    BSE: use this_thread_*() for name/getpid/gettid/online_cpus
    
    Signed-off-by: Tim Janik <timj gnu org>

 bse/bseengine.cc       |    4 ++--
 bse/bseenginemaster.cc |   10 +++++-----
 bse/bsemain.cc         |    4 ++--
 bse/bsesequencer.cc    |    4 ++--
 bse/bseserver.cc       |    8 ++++----
 5 files changed, 15 insertions(+), 15 deletions(-)
---
diff --git a/bse/bseengine.cc b/bse/bseengine.cc
index 3d68ffe..c7b754f 100644
--- a/bse/bseengine.cc
+++ b/bse/bseengine.cc
@@ -1175,7 +1175,7 @@ bse_module_new_virtual (guint       n_iostreams,
 static void
 slave (gpointer data)
 {
-  Bse::TaskRegistry::add ("DSP Slave", Bse::ThisThread::process_pid(), Bse::ThisThread::thread_pid());
+  Bse::TaskRegistry::add ("DSP Slave", Bse::this_thread_getpid(), Bse::this_thread_gettid());
   gboolean run = TRUE;
   while (run)
     {
@@ -1190,7 +1190,7 @@ slave (gpointer data)
       bse_trans_commit (trans);
       g_usleep (1000*500);
     }
-  Bse::TaskRegistry::remove (Bse::ThisThread::thread_pid());
+  Bse::TaskRegistry::remove (Bse::this_thread_gettid());
 }
 /* --- setup & trigger --- */
 static bool     bse_engine_initialized = false;
diff --git a/bse/bseenginemaster.cc b/bse/bseenginemaster.cc
index 021f1a5..63d13f7 100644
--- a/bse/bseenginemaster.cc
+++ b/bse/bseenginemaster.cc
@@ -912,7 +912,7 @@ engine_start_slaves ()
 {
   assert_return (slaves_running == false);
   slaves_running = true;
-  const uint n_cpus = Bse::ThisThread::online_cpus();
+  const uint n_cpus = Bse::this_thread_online_cpus();
   const uint n_slaves = std::max (1u, n_cpus) - 1;
   for (uint i = 0; i < n_slaves; i++)
     slave_threads.push_back (new std::thread (engine_run_slave));
@@ -945,7 +945,7 @@ void
 engine_run_slave ()
 {
   std::string myid = Bse::string_format ("DSP #%u", ++slave_counter);
-  Bse::TaskRegistry::add (myid, Bse::ThisThread::process_pid(), Bse::ThisThread::thread_pid());
+  Bse::TaskRegistry::add (myid, Bse::this_thread_getpid(), Bse::this_thread_gettid());
   while (slaves_running)
     {
       thread_process_nodes (bse_engine_block_size(), NULL); // FIXME: merge profile data
@@ -954,7 +954,7 @@ engine_run_slave ()
         break;
       slave_condition.wait (slave_lock);
     }
-  Bse::TaskRegistry::remove (Bse::ThisThread::thread_pid());
+  Bse::TaskRegistry::remove (Bse::this_thread_gettid());
 }
 
 } // BseInternal
@@ -1208,7 +1208,7 @@ static std::atomic<bool> master_thread_running { false };
 void
 MasterThread::master_thread()
 {
-  Bse::TaskRegistry::add ("DSP #1", Bse::ThisThread::process_pid(), Bse::ThisThread::thread_pid());
+  Bse::TaskRegistry::add ("DSP #1", Bse::this_thread_getpid(), Bse::this_thread_gettid());
 
   /* assert pollfd equality, since we're simply casting structures */
   static_assert (sizeof (struct pollfd) == sizeof (GPollFD), "");
@@ -1251,7 +1251,7 @@ MasterThread::master_thread()
       if (bse_engine_has_garbage ())
        caller_wakeup_();
     }
-  Bse::TaskRegistry::remove (Bse::ThisThread::thread_pid());
+  Bse::TaskRegistry::remove (Bse::this_thread_gettid());
 }
 
 static std::atomic<MasterThread*> master_thread_singleton { NULL };
diff --git a/bse/bsemain.cc b/bse/bsemain.cc
index d9b8069..5e383ae 100644
--- a/bse/bsemain.cc
+++ b/bse/bsemain.cc
@@ -218,7 +218,7 @@ static std::atomic<bool> main_loop_thread_running { true };
 static void
 bse_main_loop_thread (Bse::AsyncBlockingQueue<int> *init_queue)
 {
-  Bse::TaskRegistry::add ("BSE Core", Bse::ThisThread::process_pid(), Bse::ThisThread::thread_pid());
+  Bse::TaskRegistry::add ("BSE Core", Bse::this_thread_getpid(), Bse::this_thread_gettid());
 
   bse_init_intern ();
 
@@ -234,7 +234,7 @@ bse_main_loop_thread (Bse::AsyncBlockingQueue<int> *init_queue)
       g_main_context_iteration (bse_main_context, TRUE);
     }
 
-  Bse::TaskRegistry::remove (Bse::ThisThread::thread_pid()); // see bse_init_intern
+  Bse::TaskRegistry::remove (Bse::this_thread_gettid()); // see bse_init_intern
 }
 
 static void
diff --git a/bse/bsesequencer.cc b/bse/bsesequencer.cc
index afe812a..6891434 100644
--- a/bse/bsesequencer.cc
+++ b/bse/bsesequencer.cc
@@ -331,7 +331,7 @@ static std::atomic<bool> sequencer_thread_running { false };
 void
 Sequencer::sequencer_thread ()
 {
-  Bse::TaskRegistry::add ("Sequencer", Bse::ThisThread::process_pid(), Bse::ThisThread::thread_pid());
+  Bse::TaskRegistry::add ("Sequencer", Bse::this_thread_getpid(), Bse::this_thread_gettid());
   sequencer_thread_self = &ThreadInfo::self();
   SDEBUG ("thrdstrt: now=%llu", Bse::TickStamp::current());
   Bse::TickStampWakeupP wakeup = Bse::TickStamp::create_wakeup ([&]() { this->wakeup(); });
@@ -388,7 +388,7 @@ Sequencer::sequencer_thread ()
   while (pool_poll_Lm (-1) && sequencer_thread_running);
   BSE_SEQUENCER_UNLOCK();
   SDEBUG ("thrdstop: now=%llu", Bse::TickStamp::current());
-  Bse::TaskRegistry::remove (Bse::ThisThread::thread_pid());
+  Bse::TaskRegistry::remove (Bse::this_thread_gettid());
 }
 
 bool
diff --git a/bse/bseserver.cc b/bse/bseserver.cc
index c9870a5..4c264ad 100644
--- a/bse/bseserver.cc
+++ b/bse/bseserver.cc
@@ -1080,10 +1080,10 @@ engine_init (BseServer *server,
       engine_is_initialized = true;
       bse_engine_init();
       // lower priority compared to engine if our priority range permits
-      const int mypid = Bse::ThisThread::thread_pid();
-      int current_priority = getpriority (PRIO_PROCESS, mypid);
-      if (current_priority <= -2 && mypid)
-        setpriority (PRIO_PROCESS, mypid, current_priority + 1);
+      const int mytid = Bse::this_thread_gettid();
+      int current_priority = getpriority (PRIO_PROCESS, mytid);
+      if (current_priority <= -2 && mytid)
+        setpriority (PRIO_PROCESS, mytid, current_priority + 1);
     }
   bse_engine_configure (BSE_GCONFIG (synth_latency), mix_freq, BSE_GCONFIG (synth_control_freq));
 


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