drop g_thread_new_full()
[platform/upstream/glib.git] / glib / deprecated / gthread-deprecated.c
index 1e99694..c6aa3ef 100644 (file)
@@ -199,6 +199,7 @@ static GSList      *g_thread_all_threads = NULL;
 static GSList      *g_thread_free_indices = NULL;
 
 /* Protects g_thread_all_threads and g_thread_free_indices */
+G_LOCK_DEFINE_STATIC (g_static_mutex);
 G_LOCK_DEFINE_STATIC (g_thread);
 
 /* Misc. GThread functions {{{1 */
@@ -311,16 +312,17 @@ g_deprecated_thread_proxy (gpointer data)
  *
  * This function creates a new thread.
  *
- * If @joinable is %TRUE, you can wait for this threads termination
- * calling g_thread_join(). Otherwise the thread will just disappear
- * when it terminates.
- *
  * The new thread executes the function @func with the argument @data.
  * If the thread was created successfully, it is returned.
  *
  * @error can be %NULL to ignore errors, or non-%NULL to report errors.
  * The error is set, if and only if the function returns %NULL.
  *
+ * This function returns a reference to the created thread only if
+ * @joinable is %TRUE.  In that case, you must free this reference by
+ * calling g_thread_unref() or g_thread_join().  If @joinable is %FALSE
+ * then you should probably not touch the return value.
+ *
  * Returns: the new #GThread on success
  *
  * Deprecated:2.32: Use g_thread_new() instead
@@ -331,7 +333,7 @@ g_thread_create (GThreadFunc   func,
                  gboolean      joinable,
                  GError      **error)
 {
-  return g_thread_new_internal (NULL, g_deprecated_thread_proxy, func, data, joinable, 0, error);
+  return g_thread_create_full (func, data, 0, joinable, 0, 0, error);
 }
 
 /**
@@ -348,7 +350,7 @@ g_thread_create (GThreadFunc   func,
  * This function creates a new thread.
  *
  * Deprecated:2.32: The @bound and @priority arguments are now ignored.
- * Use g_thread_new() or g_thread_new_full() instead.
+ * Use g_thread_new().
  */
 GThread *
 g_thread_create_full (GThreadFunc       func,
@@ -359,10 +361,19 @@ g_thread_create_full (GThreadFunc       func,
                       GThreadPriority   priority,
                       GError          **error)
 {
-  return g_thread_new_internal (NULL, g_deprecated_thread_proxy, func, data, joinable, stack_size, error);
-}
+  GThread *thread;
 
+  thread = g_thread_new_internal (NULL, g_deprecated_thread_proxy,
+                                  func, data, stack_size, error);
 
+  if (!joinable)
+    {
+      thread->joinable = FALSE;
+      g_thread_unref (thread);
+    }
+
+  return thread;
+}
 
 /* GOnce {{{1 ------------------------------------------------------------- */
 gboolean
@@ -504,7 +515,7 @@ g_static_mutex_get_mutex_impl (GStaticMutex* mutex)
 
   if (!result)
     {
-      g_mutex_lock (&g_once_mutex);
+      G_LOCK (g_static_mutex);
 
       result = mutex->mutex;
       if (!result)
@@ -513,7 +524,7 @@ g_static_mutex_get_mutex_impl (GStaticMutex* mutex)
           g_atomic_pointer_set (&mutex->mutex, result);
         }
 
-      g_mutex_unlock (&g_once_mutex);
+      G_UNLOCK (g_static_mutex);
     }
 
   return result;
@@ -660,7 +671,7 @@ g_static_rec_mutex_get_rec_mutex_impl (GStaticRecMutex* mutex)
 
   if (!result)
     {
-      g_mutex_lock (&g_once_mutex);
+      G_LOCK (g_static_mutex);
 
       result = (GRecMutex *) mutex->mutex.mutex;
       if (!result)
@@ -670,7 +681,7 @@ g_static_rec_mutex_get_rec_mutex_impl (GStaticRecMutex* mutex)
           g_atomic_pointer_set (&mutex->mutex.mutex, result);
         }
 
-      g_mutex_unlock (&g_once_mutex);
+      G_UNLOCK (g_static_mutex);
     }
 
   return result;