[beast: 8/10] BSE: provide Bse::init_needed()



commit 2b697f06fa986df337f12c140784e03bcbb078b9
Author: Tim Janik <timj gnu org>
Date:   Mon Jan 25 00:25:41 2016 +0100

    BSE: provide Bse::init_needed()
    
    Signed-off-by: Tim Janik <timj gnu org>

 bse/bsemain.cc    |    8 +++++++-
 bse/bsemain.hh    |    1 +
 bse/bsestartup.cc |    7 +++++++
 bse/bsestartup.hh |    1 +
 4 files changed, 16 insertions(+), 1 deletions(-)
---
diff --git a/bse/bsemain.cc b/bse/bsemain.cc
index 51c7c86..474871b 100644
--- a/bse/bsemain.cc
+++ b/bse/bsemain.cc
@@ -191,10 +191,16 @@ bse_init_intern()
 
 static std::thread async_bse_thread;
 
+bool
+_bse_initialized ()
+{
+  return async_bse_thread.get_id() != std::thread::id(); // has async_bse_thread started?
+}
+
 static void
 initialize_with_argv (int *argc, char **argv, const char *app_name, const Bse::StringVector &args)
 {
-  assert (async_bse_thread.get_id() == std::thread::id());      // no async_bse_thread started
+  assert (_bse_initialized() == false);
   assert (bse_main_context == NULL);
 
   // ensure textdomain for error messages
diff --git a/bse/bsemain.hh b/bse/bsemain.hh
index 72367b0..cd3aedd 100644
--- a/bse/bsemain.hh
+++ b/bse/bsemain.hh
@@ -7,6 +7,7 @@ G_BEGIN_DECLS
 // == BSE Initialization ==
 void bse_bindtextdomain ();
 void _bse_init_async   (int *argc, char **argv, const char *app_name, const Bse::StringVector &args);
+bool _bse_initialized  ();
 void bse_init_inprocess        (int *argc, char **argv, const char *app_name, const Bse::StringVector &args 
= Bse::StringVector());
 void bse_init_test     (int *argc, char **argv, const Bse::StringVector &args = Bse::StringVector());
 void bse_main_wakeup    ();
diff --git a/bse/bsestartup.cc b/bse/bsestartup.cc
index 54c566e..6f954be 100644
--- a/bse/bsestartup.cc
+++ b/bse/bsestartup.cc
@@ -29,6 +29,13 @@ init_async (int *argc, char **argv, const char *app_name, const StringVector &ar
   _bse_init_async (argc, argv, app_name, args);
 }
 
+/// Check wether init_async() still needs to be called.
+bool
+init_needed ()
+{
+  return _bse_initialized() == false;
+}
+
 // == TaskRegistry ==
 static Bse::Mutex         task_registry_mutex_;
 static TaskRegistry::List task_registry_tasks_;
diff --git a/bse/bsestartup.hh b/bse/bsestartup.hh
index 6ff5f08..4bb5cd7 100644
--- a/bse/bsestartup.hh
+++ b/bse/bsestartup.hh
@@ -24,6 +24,7 @@ public:
 
 SfiGlueContext*        init_glue_context   (const gchar *client, const std::function<void()> &caller_wakeup);
 void           init_async          (int *argc, char **argv, const char *app_name, const StringVector &args = 
StringVector());
+bool           init_needed         ();
 
 /// A GSource implementation to attach an Aida::BaseConnection to a Glib main loop.
 class AidaGlibSource : public GSource {


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