[beast: 51/95] BIRNET: eliminate old thread wakeups



commit be8851b03b1fd51dafa89b7157219aa09f80d222
Author: Tim Janik <timj gnu org>
Date:   Tue Mar 19 03:34:39 2013 +0100

    BIRNET: eliminate old thread wakeups

 beast-gtk/bstmain.cc   |    1 -
 beast-gtk/testgui.cc   |    1 -
 birnet/birnetthread.cc |   22 ----------------------
 birnet/birnetthread.hh |    6 ------
 bse/bsemain.cc         |    2 --
 bse/gslcommon.cc       |   23 ++++++++++++-----------
 sfi/sfiwrapper.hh      |    5 -----
 sfi/tests/misctests.cc |   10 +---------
 shell/bsescm.cc        |    5 ++---
 9 files changed, 15 insertions(+), 60 deletions(-)
---
diff --git a/beast-gtk/bstmain.cc b/beast-gtk/bstmain.cc
index ddbe5c7..4c656c9 100644
--- a/beast-gtk/bstmain.cc
+++ b/beast-gtk/bstmain.cc
@@ -90,7 +90,6 @@ main (int   argc,
   sfi_msg_allow ("misc");
   /* ensure SFI can wake us up */
   sfi_thread_set_name ("Beast GUI");
-  sfi_thread_set_wakeup ((BirnetThreadWakeup) bst_main_loop_wakeup, NULL, NULL);
   /* initialize Gtk+ and go into threading mode */
   bst_early_parse_args (&argc, &argv);
   if (bst_debug_extensions)
diff --git a/beast-gtk/testgui.cc b/beast-gtk/testgui.cc
index 9f28d59..6362525 100644
--- a/beast-gtk/testgui.cc
+++ b/beast-gtk/testgui.cc
@@ -77,7 +77,6 @@ main (int   argc,
   sfi_msg_allow ("misc");
   /* ensure SFI can wake us up */
   sfi_thread_set_name ("TestGUI");
-  sfi_thread_set_wakeup ((BirnetThreadWakeup) g_main_context_wakeup, g_main_context_default (), NULL);
   /* initialize Gtk+ and enter threading mode */
   gtk_init (&argc, &argv);
   g_set_prgname ("testgui");            /* override Gdk's program name */
diff --git a/birnet/birnetthread.cc b/birnet/birnetthread.cc
index 7ac4ede..061ea1d 100644
--- a/birnet/birnetthread.cc
+++ b/birnet/birnetthread.cc
@@ -107,11 +107,6 @@ Thread::start ()
         ThreadTable.thread_yield();
     }
 }
-void
-Thread::emit_wakeups (uint64 stamp)
-{
-  ThreadTable.thread_emit_wakeups (stamp);
-}
 int
 Thread::pid () const
 {
@@ -137,11 +132,6 @@ Thread::aborted ()
 {
   return ThreadTable.thread_get_aborted (bthread);
 }
-void
-Thread::wakeup ()
-{
-  ThreadTable.thread_wakeup (bthread);
-}
 bool
 Thread::running ()
 {
@@ -189,18 +179,6 @@ Thread::Self::pid ()
 {
   return ThreadTable.thread_pid (ThreadTable.thread_self());
 }
-void
-Thread::Self::awake_after (uint64 stamp)
-{
-  ThreadTable.thread_awake_after (stamp);
-}
-void
-Thread::Self::set_wakeup (BirnetThreadWakeup   wakeup_func,
-                          void                *wakeup_data,
-                          void               (*destroy_data) (void*))
-{
-  ThreadTable.thread_set_wakeup (wakeup_func, wakeup_data, destroy_data);
-}
 OwnedMutex&
 Thread::Self::owned_mutex ()
 {
diff --git a/birnet/birnetthread.hh b/birnet/birnetthread.hh
index 2a43876..59ea66e 100644
--- a/birnet/birnetthread.hh
+++ b/birnet/birnetthread.hh
@@ -88,14 +88,12 @@ public:
   void                  queue_abort     ();
   void                  abort           ();
   bool                  aborted         ();
-  void                  wakeup          ();
   bool                  running         ();
   void                  wait_for_exit   ();
   /* event loop */
   void                  exec_loop       ();
   void                  quit_loop       ();
   /* global methods */
-  static void           emit_wakeups    (uint64             stamp);
   static Thread&        self            ();
   /* Self thread */
   struct Self {
@@ -104,10 +102,6 @@ public:
     static bool         sleep           (long               max_useconds);
     static bool         aborted         ();
     static int          pid             ();
-    static void         awake_after     (uint64             stamp);
-    static void         set_wakeup      (BirnetThreadWakeup wakeup_func,
-                                         void              *wakeup_data,
-                                         void             (*destroy_data) (void*));
     static OwnedMutex&  owned_mutex     ();
     static void         yield           ();
     static void         exit            (void              *retval = NULL) BIRNET_NORETURN;
diff --git a/bse/bsemain.cc b/bse/bsemain.cc
index 04f23d0..2ac56ec 100644
--- a/bse/bsemain.cc
+++ b/bse/bsemain.cc
@@ -181,8 +181,6 @@ bse_init_core (void)
 {
   /* global threading things */
   bse_main_context = g_main_context_new ();
-  sfi_thread_set_wakeup ((BirnetThreadWakeup) g_main_context_wakeup,
-                        bse_main_context, NULL);
   bse_message_setup_thread_handler();
   /* initialize basic components */
   bse_globals_init ();
diff --git a/bse/gslcommon.cc b/bse/gslcommon.cc
index d49b569..4da3db9 100644
--- a/bse/gslcommon.cc
+++ b/bse/gslcommon.cc
@@ -54,20 +54,21 @@ TickStamp::_increment ()
 
 #ifdef  RAPICORN_DOXYGEN
 /**
- * @return GSL's execution tick stamp as unsigned 64bit integer
+ * Retrieve BSE execution tick stamp as unsigned 64bit integer.
  *
- * Retrieve the global GSL tick counter stamp.
- * GSL increments its global tick stamp at certain intervals,
+ * Returns the global GSL tick counter stamp.
+ * BSE increments its global tick stamp at certain intervals,
  * by specific amounts (refer to bse_engine_init() for further
  * details). The tick stamp is a non-wrapping, unsigned 64bit
- * integer greater than 0. Threads can schedule sleep interruptions
- * at certain tick stamps with sfi_thread_awake_after() and
- * sfi_thread_awake_before(). Tick stamp updating occours at
- * GSL engine block processing boundaries, so code that can
- * guarantee to not run across those boundaries (for instance
- * BseProcessFunc() functions) may use the macro Bse::TickStamp::current()
- * to retrieve the current tick in a faster manner (not involving
- * mutex locking). See also bse_module_tick_stamp().
+ * integer greater than 0.
+ * Threads can schedule sleep interruptions at certain tick
+ * stamps with awake_after() and awake_before().
+ * Tick stamp updating occours at BSE engine block processing
+ * boundaries, so code that can guarantee to not run across
+ * those boundaries (for instance BseProcessFunc() functions)
+ * may use Bse::TickStamp::current() to retrieve the current
+ * tick in a fast manner (not involving mutex locking).
+ * See also bse_module_tick_stamp().
  * This function is MT-safe and may be called from any thread.
  */
 uint64 TickStamp::current () { ... }
diff --git a/sfi/sfiwrapper.hh b/sfi/sfiwrapper.hh
index 769de2c..315fd62 100644
--- a/sfi/sfiwrapper.hh
+++ b/sfi/sfiwrapper.hh
@@ -162,7 +162,6 @@ void birnet_cleanup_force_handlers     (void); // FIXME: remove
 /* --- threading API --- */
 typedef BirnetThread                   SfiThread;
 typedef void                 (*SfiThreadFunc)   (void *user_data);
-typedef void                 (*SfiThreadWakeup) (void *wakeup_data);
 typedef BirnetCond                     SfiCond;
 typedef BirnetMutex                    SfiMutex;
 typedef BirnetRecMutex                 SfiRecMutex;
@@ -209,10 +208,6 @@ SfiThread* sfi_thread_run                  (const char   *name, /* new + start */
 #define sfi_thread_get_name(thrd)              (sfi_thread_table->thread_name (thrd))
 #define sfi_thread_set_name(name)              (sfi_thread_table->thread_set_name (name))
 #define sfi_thread_sleep(usecs)                        (sfi_thread_table->thread_sleep (usecs))
-#define sfi_thread_wakeup(thrd)                        (sfi_thread_table->thread_wakeup (thrd))
-#define sfi_thread_awake_after(stamp)          (sfi_thread_table->thread_awake_after (stamp))
-#define sfi_thread_emit_wakeups(stamp)         (sfi_thread_table->thread_emit_wakeups (stamp))
-#define sfi_thread_set_wakeup(func,udata,dstry)        (sfi_thread_table->thread_set_wakeup (func, udata, 
dstry))
 #define sfi_thread_abort(thrd)                 (sfi_thread_table->thread_abort (thrd))
 #define sfi_thread_queue_abort(thrd)           (sfi_thread_table->thread_queue_abort (thrd))
 #define sfi_thread_aborted()                   (sfi_thread_table->thread_aborted ())
diff --git a/sfi/tests/misctests.cc b/sfi/tests/misctests.cc
index feecbed..ab9f266 100644
--- a/sfi/tests/misctests.cc
+++ b/sfi/tests/misctests.cc
@@ -147,10 +147,9 @@ static void
 test_thread (gpointer data)
 {
   guint *tdata = (guint*) data;
-  sfi_thread_sleep (-1);
   *tdata += 1;
   while (!sfi_thread_aborted ())
-    sfi_thread_sleep (-1);
+    sfi_thread_sleep (1);
   TACK ();
 }
 static void
@@ -168,8 +167,6 @@ test_threads (void)
   sfi_mutex_destroy (&test_mutex);
   thread = sfi_thread_run ("sfi-test-thread", test_thread, &thread_data);
   TASSERT (thread != NULL);
-  TASSERT (thread_data == 0);
-  sfi_thread_wakeup (thread);
   sfi_thread_abort (thread);
   TASSERT (thread_data > 0);
   sfi_thread_unref (thread);
@@ -569,7 +566,6 @@ check_thread_wrapper_compilation (void)
   const char *name = NULL;
   void *udata = NULL;
   BirnetThreadFunc thread_func = NULL;
-  BirnetThreadWakeup wakeup_func = NULL;
   GDestroyNotify dstry = NULL;
   BirnetInt64 stamp = 31;
   BirnetThreadInfo *tinfo;
@@ -585,10 +581,6 @@ check_thread_wrapper_compilation (void)
   name = sfi_thread_get_name (thrd);
   sfi_thread_set_name (name);
   sfi_thread_sleep (usecs);
-  sfi_thread_wakeup (thrd);
-  sfi_thread_awake_after (stamp);
-  sfi_thread_emit_wakeups (stamp);
-  sfi_thread_set_wakeup (wakeup_func, udata, dstry);
   sfi_thread_abort (thrd);
   sfi_thread_queue_abort (thrd);
   boolv = sfi_thread_aborted ();
diff --git a/shell/bsescm.cc b/shell/bsescm.cc
index b4e3261..722941c 100644
--- a/shell/bsescm.cc
+++ b/shell/bsescm.cc
@@ -77,14 +77,13 @@ main (int   argc,
     }
   if (!bse_scm_context)
     {
-      /* start our own core thread */
+      // start our own core thread
       Bse::init_async (&argc, &argv, "BSESCM", NULL);
+      // allow g_main_context_wakeup to interrupt sleeps in bse_scm_context_iteration
       bse_scm_context = Bse::init_glue_context (PRG_NAME, []() { g_main_context_wakeup 
(g_main_context_default()); });
     }
   /* now that the BSE thread runs, drop scheduling priorities if we have any */
   setpriority (PRIO_PROCESS, getpid(), 0);
-  /* setup main context to be able to wait for events from bse in bse_scm_context_iteration */
-  sfi_thread_set_wakeup (BirnetThreadWakeup (g_main_context_wakeup), g_main_context_default(), NULL);
   source = g_source_simple (G_PRIORITY_DEFAULT, GSourcePending (sfi_glue_context_pending), dummy_dispatch, 
NULL, NULL, NULL);
   g_source_attach (source, NULL);
   g_source_unref (source);


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