From 8cff9c57b1cbb443aa4063d8624af8a7bb392b75 Mon Sep 17 00:00:00 2001 From: Ryan Lortie Date: Wed, 12 Oct 2011 21:44:07 -0400 Subject: [PATCH] thread: drop thread setup function hackery Use a custom proxy function for the deprecated case instead. Now GRealThread has strictly zero members dedicated to deprecated functionality. --- glib/deprecated/gthread-deprecated.c | 15 +++++++++++++-- glib/gthread.c | 17 ++++++----------- glib/gthreadprivate.h | 7 ++++--- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/glib/deprecated/gthread-deprecated.c b/glib/deprecated/gthread-deprecated.c index 45cb911ad..1e99694c3 100644 --- a/glib/deprecated/gthread-deprecated.c +++ b/glib/deprecated/gthread-deprecated.c @@ -291,6 +291,17 @@ g_enumerable_thread_add (GRealThread *thread) g_private_set (&enumerable_thread_private, thread); } + +static gpointer +g_deprecated_thread_proxy (gpointer data) +{ + GRealThread *real = data; + + g_enumerable_thread_add (real); + + return g_thread_proxy (data); +} + /** * g_thread_create: * @func: a function to execute in the new thread @@ -320,7 +331,7 @@ g_thread_create (GThreadFunc func, gboolean joinable, GError **error) { - return g_thread_new_internal (NULL, func, data, joinable, 0, g_enumerable_thread_add, error); + return g_thread_new_internal (NULL, g_deprecated_thread_proxy, func, data, joinable, 0, error); } /** @@ -348,7 +359,7 @@ g_thread_create_full (GThreadFunc func, GThreadPriority priority, GError **error) { - return g_thread_new_internal (NULL, func, data, joinable, stack_size, g_enumerable_thread_add, error); + return g_thread_new_internal (NULL, g_deprecated_thread_proxy, func, data, joinable, stack_size, error); } diff --git a/glib/gthread.c b/glib/gthread.c index 23fd703db..27cdc0854 100644 --- a/glib/gthread.c +++ b/glib/gthread.c @@ -681,8 +681,8 @@ g_thread_cleanup (gpointer data) } } -static gpointer -g_thread_create_proxy (gpointer data) +gpointer +g_thread_proxy (gpointer data) { GRealThread* thread = data; @@ -694,9 +694,6 @@ 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->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(). */ @@ -743,7 +740,7 @@ g_thread_new (const gchar *name, gboolean joinable, GError **error) { - return g_thread_new_internal (name, func, data, joinable, 0, FALSE, error); + return g_thread_new_internal (name, g_thread_proxy, func, data, joinable, 0, error); } /** @@ -790,16 +787,16 @@ g_thread_new_full (const gchar *name, gsize stack_size, GError **error) { - return g_thread_new_internal (name, func, data, joinable, stack_size, FALSE, error); + return g_thread_new_internal (name, g_thread_proxy, func, data, joinable, stack_size, error); } GThread * g_thread_new_internal (const gchar *name, + GThreadFunc proxy, GThreadFunc func, gpointer data, gboolean joinable, gsize stack_size, - GThreadSetup setup_func, GError **error) { GRealThread *result; @@ -812,11 +809,9 @@ g_thread_new_internal (const gchar *name, result->thread.joinable = joinable; result->thread.func = func; result->thread.data = data; - result->setup_func = setup_func; result->name = name; G_LOCK (g_thread_new); - g_system_thread_create (g_thread_create_proxy, result, - stack_size, joinable, + g_system_thread_create (proxy, result, stack_size, joinable, &result->system_thread, &local_error); G_UNLOCK (g_thread_new); diff --git a/glib/gthreadprivate.h b/glib/gthreadprivate.h index 3f9fa9b3a..3aebf7241 100644 --- a/glib/gthreadprivate.h +++ b/glib/gthreadprivate.h @@ -30,7 +30,6 @@ G_BEGIN_DECLS typedef struct _GRealThread GRealThread; -typedef void (*GThreadSetup) (GRealThread *thread); G_GNUC_INTERNAL void g_system_thread_join (gpointer thread); G_GNUC_INTERNAL void g_system_thread_create (GThreadFunc func, @@ -44,18 +43,20 @@ G_GNUC_INTERNAL void g_system_thread_exit (void); G_GNUC_INTERNAL void g_system_thread_set_name (const gchar *name); G_GNUC_INTERNAL GThread *g_thread_new_internal (const gchar *name, + GThreadFunc proxy, GThreadFunc func, gpointer data, gboolean joinable, gsize stack_size, - GThreadSetup setup_func, GError **error); +G_GNUC_INTERNAL +gpointer g_thread_proxy (gpointer thread); + struct _GRealThread { GThread thread; const gchar *name; - GThreadSetup setup_func; gpointer retval; GSystemThread system_thread; };