mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-10-18 03:12:52 +02:00
thread: use GPrivate for enumerable threads
Use a GPrivate to track the destruction of enumerable threads and remove them from the list.
This commit is contained in:
@@ -332,18 +332,10 @@ g_thread_foreach (GFunc thread_func,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
g_enumerable_thread_add (GRealThread *thread)
|
||||
{
|
||||
G_LOCK (g_thread);
|
||||
thread->next = g_thread_all_threads;
|
||||
g_thread_all_threads = thread;
|
||||
G_UNLOCK (g_thread);
|
||||
}
|
||||
|
||||
void
|
||||
g_enumerable_thread_remove (GRealThread *thread)
|
||||
static void
|
||||
g_enumerable_thread_remove (gpointer data)
|
||||
{
|
||||
GRealThread *thread = data;
|
||||
GRealThread *t, *p;
|
||||
|
||||
G_LOCK (g_thread);
|
||||
@@ -361,6 +353,19 @@ g_enumerable_thread_remove (GRealThread *thread)
|
||||
G_UNLOCK (g_thread);
|
||||
}
|
||||
|
||||
GPrivate enumerable_thread_private = G_PRIVATE_INIT (g_enumerable_thread_remove);
|
||||
|
||||
void
|
||||
g_enumerable_thread_add (GRealThread *thread)
|
||||
{
|
||||
G_LOCK (g_thread);
|
||||
thread->next = g_thread_all_threads;
|
||||
g_thread_all_threads = thread;
|
||||
G_UNLOCK (g_thread);
|
||||
|
||||
g_private_set (&enumerable_thread_private, thread);
|
||||
}
|
||||
|
||||
/* GOnce {{{1 ------------------------------------------------------------- */
|
||||
gboolean
|
||||
g_once_init_enter_impl (volatile gsize *location)
|
||||
|
Reference in New Issue
Block a user