mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 19:36:18 +01:00
thread: use GSList for g_thread_foreach list
...instead of having a 'next' pointer in the GThread struct. Now GThread contains no fields used only by deprecated code (except for the rather generic setup function field).
This commit is contained in:
parent
9ca4f14264
commit
96904b6790
@ -197,7 +197,7 @@ void g_thread_init_glib (void) { }
|
|||||||
|
|
||||||
/* Internal variables {{{1 */
|
/* Internal variables {{{1 */
|
||||||
|
|
||||||
static GRealThread *g_thread_all_threads = NULL;
|
static GSList *g_thread_all_threads = NULL;
|
||||||
static GSList *g_thread_free_indices = NULL;
|
static GSList *g_thread_free_indices = NULL;
|
||||||
|
|
||||||
/* Protects g_thread_all_threads and g_thread_free_indices */
|
/* Protects g_thread_all_threads and g_thread_free_indices */
|
||||||
@ -252,8 +252,7 @@ g_thread_foreach (GFunc thread_func,
|
|||||||
g_return_if_fail (thread_func != NULL);
|
g_return_if_fail (thread_func != NULL);
|
||||||
/* snapshot the list of threads for iteration */
|
/* snapshot the list of threads for iteration */
|
||||||
G_LOCK (g_thread);
|
G_LOCK (g_thread);
|
||||||
for (thread = g_thread_all_threads; thread; thread = thread->next)
|
slist = g_slist_copy (g_thread_all_threads);
|
||||||
slist = g_slist_prepend (slist, thread);
|
|
||||||
G_UNLOCK (g_thread);
|
G_UNLOCK (g_thread);
|
||||||
/* walk the list, skipping non-existent threads */
|
/* walk the list, skipping non-existent threads */
|
||||||
while (slist)
|
while (slist)
|
||||||
@ -262,9 +261,10 @@ g_thread_foreach (GFunc thread_func,
|
|||||||
slist = node->next;
|
slist = node->next;
|
||||||
/* check whether the current thread still exists */
|
/* check whether the current thread still exists */
|
||||||
G_LOCK (g_thread);
|
G_LOCK (g_thread);
|
||||||
for (thread = g_thread_all_threads; thread; thread = thread->next)
|
if (g_slist_find (g_thread_all_threads, node->data))
|
||||||
if (thread == node->data)
|
thread = node->data;
|
||||||
break;
|
else
|
||||||
|
thread = NULL;
|
||||||
G_UNLOCK (g_thread);
|
G_UNLOCK (g_thread);
|
||||||
if (thread)
|
if (thread)
|
||||||
thread_func (thread, user_data);
|
thread_func (thread, user_data);
|
||||||
@ -276,20 +276,9 @@ static void
|
|||||||
g_enumerable_thread_remove (gpointer data)
|
g_enumerable_thread_remove (gpointer data)
|
||||||
{
|
{
|
||||||
GRealThread *thread = data;
|
GRealThread *thread = data;
|
||||||
GRealThread *t, *p;
|
|
||||||
|
|
||||||
G_LOCK (g_thread);
|
G_LOCK (g_thread);
|
||||||
for (t = g_thread_all_threads, p = NULL; t; p = t, t = t->next)
|
g_thread_all_threads = g_slist_remove (g_thread_all_threads, thread);
|
||||||
{
|
|
||||||
if (t == thread)
|
|
||||||
{
|
|
||||||
if (p)
|
|
||||||
p->next = t->next;
|
|
||||||
else
|
|
||||||
g_thread_all_threads = t->next;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
G_UNLOCK (g_thread);
|
G_UNLOCK (g_thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,8 +288,7 @@ static void
|
|||||||
g_enumerable_thread_add (GRealThread *thread)
|
g_enumerable_thread_add (GRealThread *thread)
|
||||||
{
|
{
|
||||||
G_LOCK (g_thread);
|
G_LOCK (g_thread);
|
||||||
thread->next = g_thread_all_threads;
|
g_thread_all_threads = g_slist_prepend (g_thread_all_threads, thread);
|
||||||
g_thread_all_threads = thread;
|
|
||||||
G_UNLOCK (g_thread);
|
G_UNLOCK (g_thread);
|
||||||
|
|
||||||
g_private_set (&enumerable_thread_private, thread);
|
g_private_set (&enumerable_thread_private, thread);
|
||||||
|
@ -66,7 +66,6 @@ G_GNUC_INTERNAL GThread *g_thread_new_internal (const gchar *name,
|
|||||||
struct _GRealThread
|
struct _GRealThread
|
||||||
{
|
{
|
||||||
GThread thread;
|
GThread thread;
|
||||||
GRealThread *next;
|
|
||||||
const gchar *name;
|
const gchar *name;
|
||||||
GThreadSetup setup_func;
|
GThreadSetup setup_func;
|
||||||
gpointer retval;
|
gpointer retval;
|
||||||
|
Loading…
Reference in New Issue
Block a user