thread: reduce use of system_thread
[platform/upstream/glib.git] / glib / gthread.c
index e6e1901..23fd703 100644 (file)
@@ -677,11 +677,7 @@ g_thread_cleanup (gpointer data)
        * If it is, the structure is freed in g_thread_join()
        */
       if (!thread->thread.joinable)
-        {
-          /* Just to make sure, this isn't used any more */
-          g_system_thread_assign (thread->system_thread, zero_thread);
-          g_free (thread);
-        }
+        g_free (thread);
     }
 }
 
@@ -698,8 +694,8 @@ g_thread_create_proxy (gpointer data)
   /* This has to happen before G_LOCK, as that might call g_thread_self */
   g_private_set (&g_thread_specific_private, data);
 
-  if (thread->enumerable)
-    g_enumerable_thread_add (thread);
+  if (thread->setup_func)
+    thread->setup_func (thread);
 
   /* The lock makes sure that thread->system_thread is written,
    * before thread->thread.func is called. See g_thread_new_internal().
@@ -798,13 +794,13 @@ g_thread_new_full (const gchar  *name,
 }
 
 GThread *
-g_thread_new_internal (const gchar  *name,
-                       GThreadFunc   func,
-                       gpointer      data,
-                       gboolean      joinable,
-                       gsize         stack_size,
-                       gboolean      enumerable,
-                       GError      **error)
+g_thread_new_internal (const gchar   *name,
+                       GThreadFunc    func,
+                       gpointer       data,
+                       gboolean       joinable,
+                       gsize          stack_size,
+                       GThreadSetup   setup_func,
+                       GError       **error)
 {
   GRealThread *result;
   GError *local_error = NULL;
@@ -816,7 +812,7 @@ g_thread_new_internal (const gchar  *name,
   result->thread.joinable = joinable;
   result->thread.func = func;
   result->thread.data = data;
-  result->enumerable = enumerable;
+  result->setup_func = setup_func;
   result->name = name;
   G_LOCK (g_thread_new);
   g_system_thread_create (g_thread_create_proxy, result,
@@ -891,7 +887,6 @@ g_thread_join (GThread *thread)
 
   g_return_val_if_fail (thread, NULL);
   g_return_val_if_fail (thread->joinable, NULL);
-  g_return_val_if_fail (!g_system_thread_equal (&real->system_thread, &zero_thread), NULL);
 
   g_system_thread_join (&real->system_thread);
 
@@ -899,7 +894,6 @@ g_thread_join (GThread *thread)
 
   /* Just to make sure, this isn't used any more */
   thread->joinable = 0;
-  g_system_thread_assign (real->system_thread, zero_thread);
 
   /* the thread structure for non-joinable threads is freed upon
    * thread end. We free the memory here. This will leave a loose end,
@@ -933,9 +927,6 @@ g_thread_self (void)
       thread->thread.joinable = FALSE; /* This is a safe guess */
       thread->thread.func = NULL;
       thread->thread.data = NULL;
-      thread->enumerable = FALSE;
-
-      g_system_thread_self (&thread->system_thread);
 
       g_private_set (&g_thread_specific_private, thread);
     }