[clutter] Deprecate clutter_threads_init()



commit 7e3a75c66bbca1e278b15c797cfc6acbcbd6c7c7
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Fri Oct 7 15:53:50 2011 +0100

    Deprecate clutter_threads_init()
    
    GLib deprecated g_thread_init(), and threading support is initialized
    by GObject, so Clutter already runs with threading support enabled. We
    can drop the clutter_threads_init() call requirement, and initialize the
    Big Clutter Lockâ on clutter_init(). This reduces the things that have
    to be done when dealing with threads with Clutter, and the things that
    can possibly go wrong.

 clutter/clutter-main.c                    |   55 ++++++++++++++++------------
 clutter/clutter-main.h                    |    3 ++
 tests/interactive/test-texture-async.c    |    4 +-
 tests/interactive/test-texture-material.c |    2 -
 tests/interactive/test-threads.c          |    2 -
 5 files changed, 36 insertions(+), 30 deletions(-)
---
diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c
index 9fe9acd..834731e 100644
--- a/clutter/clutter-main.c
+++ b/clutter/clutter-main.c
@@ -34,7 +34,7 @@
  *   <para>Clutter is <emphasis>thread-aware</emphasis>: all operations
  *   performed by Clutter are assumed to be under the big Clutter lock,
  *   which is created when the threading is initialized through
- *   clutter_threads_init().</para>
+ *   clutter_init().</para>
  *   <example id="example-Thread-Init">
  *     <title>Thread Initialization</title>
  *     <para>The code below shows how to correctly initialize Clutter
@@ -44,12 +44,6 @@
  * int
  * main (int argc, char *argv[])
  * {
- *   /&ast; initialize GLib's threading support &ast;/
- *   g_thread_init (NULL);
- *
- *   /&ast; initialize Clutter's threading support &ast;/
- *   clutter_threads_init ();
- *
  *   /&ast; initialize Clutter &ast;/
  *   clutter_init (&amp;argc, &amp;argv);
  *
@@ -195,6 +189,30 @@ static const GDebugKey clutter_profile_keys[] = {
 };
 #endif /* CLUTTER_ENABLE_DEBUG */
 
+static void
+clutter_threads_impl_lock (void)
+{
+  g_mutex_lock (&clutter_threads_mutex);
+}
+
+static void
+clutter_threads_impl_unlock (void)
+{
+  g_mutex_unlock (&clutter_threads_mutex);
+}
+
+static inline void
+clutter_threads_init_default (void)
+{
+  g_mutex_init (&clutter_threads_mutex);
+
+  if (clutter_threads_lock == NULL)
+    clutter_threads_lock = clutter_threads_impl_lock;
+
+  if (clutter_threads_unlock == NULL)
+    clutter_threads_unlock = clutter_threads_impl_unlock;
+}
+
 /**
  * clutter_get_show_fps:
  *
@@ -691,18 +709,6 @@ clutter_main (void)
     CLUTTER_TIMER_STOP (uprof_get_mainloop_context (), mainloop_timer);
 }
 
-static void
-clutter_threads_impl_lock (void)
-{
-  g_mutex_lock (&clutter_threads_mutex);
-}
-
-static void
-clutter_threads_impl_unlock (void)
-{
-  g_mutex_unlock (&clutter_threads_mutex);
-}
-
 /**
  * clutter_threads_init:
  *
@@ -717,15 +723,13 @@ clutter_threads_impl_unlock (void)
  * It is safe to call this function multiple times.
  *
  * Since: 0.4
+ *
+ * Deprecated: 1.10: This function does not do anything. Threading support
+ *   is initialized when Clutter is initialized.
  */
 void
 clutter_threads_init (void)
 {
-  if (clutter_threads_lock == NULL)
-    clutter_threads_lock = clutter_threads_impl_lock;
-
-  if (clutter_threads_unlock == NULL)
-    clutter_threads_unlock = clutter_threads_impl_unlock;
 }
 
 /**
@@ -2356,6 +2360,9 @@ clutter_base_init (void)
 
       /* initialise GLib type system */
       g_type_init ();
+
+      /* initialise the Big Clutter Lockâ if necessary */
+      clutter_threads_init_default ();
     }
 }
 
diff --git a/clutter/clutter-main.h b/clutter/clutter-main.h
index f2d821e..a99a694 100644
--- a/clutter/clutter-main.h
+++ b/clutter/clutter-main.h
@@ -107,7 +107,10 @@ gulong           clutter_get_timestamp              (void);
 gboolean         clutter_get_accessibility_enabled  (void);
 
 /* Threading functions */
+#ifndef CLUTTER_DISABLE_DEPRECATED
 void             clutter_threads_init                  (void);
+#endif
+
 void             clutter_threads_enter                 (void);
 void             clutter_threads_leave                 (void);
 void             clutter_threads_set_lock_functions    (GCallback enter_fn,
diff --git a/tests/interactive/test-texture-async.c b/tests/interactive/test-texture-async.c
index 7e09f36..20d802b 100644
--- a/tests/interactive/test-texture-async.c
+++ b/tests/interactive/test-texture-async.c
@@ -120,8 +120,6 @@ test_texture_async_main (int argc, char *argv[])
 {
   gchar *path;
 
-  clutter_threads_init ();
-
   if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
     return 1;
 
@@ -140,7 +138,9 @@ test_texture_async_main (int argc, char *argv[])
                                     task, path,
                                     cleanup_task);
 
+  clutter_threads_enter ();
   clutter_main ();
+  clutter_threads_leave ();
 
   g_free (path);
 
diff --git a/tests/interactive/test-texture-material.c b/tests/interactive/test-texture-material.c
index 867711f..4886ce0 100644
--- a/tests/interactive/test-texture-material.c
+++ b/tests/interactive/test-texture-material.c
@@ -10,8 +10,6 @@ test_texture_material_main (int argc, char *argv[])
   ClutterLayoutManager *manager;
   int i;
 
-  g_thread_init (NULL);
-  clutter_threads_init ();
   if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
     return 1;
 
diff --git a/tests/interactive/test-threads.c b/tests/interactive/test-threads.c
index dd7a2f8..fd73eaf 100644
--- a/tests/interactive/test-threads.c
+++ b/tests/interactive/test-threads.c
@@ -188,8 +188,6 @@ test_threads_main (int argc, char *argv[])
     { 400, 150 }
   };
 
-  g_thread_init (NULL);
-  clutter_threads_init ();
   if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
     return 1;
 



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