thread: call g_enumerable_thread_add via callback

There are no longer any functions defined in gthread-deprecated.c called
from gthread.c.
This commit is contained in:
Ryan Lortie 2011-10-12 16:50:43 -04:00
parent f788a2e5e1
commit 9ca4f14264
3 changed files with 83 additions and 83 deletions

View File

@ -220,66 +220,6 @@ g_thread_set_priority (GThread *thread,
{
}
/**
* g_thread_create:
* @func: a function to execute in the new thread
* @data: an argument to supply to the new thread
* @joinable: should this thread be joinable?
* @error: return location for error, or %NULL
*
* 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.
*
* Returns: the new #GThread on success
*
* Deprecated:2.32: Use g_thread_new() instead
*/
GThread *
g_thread_create (GThreadFunc func,
gpointer data,
gboolean joinable,
GError **error)
{
return g_thread_new_internal (NULL, func, data, joinable, 0, TRUE, error);
}
/**
* g_thread_create_full:
* @func: a function to execute in the new thread.
* @data: an argument to supply to the new thread.
* @stack_size: a stack size for the new thread.
* @joinable: should this thread be joinable?
* @bound: ignored
* @priority: ignored
* @error: return location for error.
* @Returns: the new #GThread on success.
*
* 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.
*/
GThread *
g_thread_create_full (GThreadFunc func,
gpointer data,
gulong stack_size,
gboolean joinable,
gboolean bound,
GThreadPriority priority,
GError **error)
{
return g_thread_new_internal (NULL, func, data, joinable, stack_size, TRUE, error);
}
/**
* g_thread_foreach:
* @thread_func: function to call for all #GThread structures
@ -355,7 +295,7 @@ g_enumerable_thread_remove (gpointer data)
GPrivate enumerable_thread_private = G_PRIVATE_INIT (g_enumerable_thread_remove);
void
static void
g_enumerable_thread_add (GRealThread *thread)
{
G_LOCK (g_thread);
@ -365,6 +305,67 @@ g_enumerable_thread_add (GRealThread *thread)
g_private_set (&enumerable_thread_private, thread);
}
/**
* g_thread_create:
* @func: a function to execute in the new thread
* @data: an argument to supply to the new thread
* @joinable: should this thread be joinable?
* @error: return location for error, or %NULL
*
* 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.
*
* Returns: the new #GThread on success
*
* Deprecated:2.32: Use g_thread_new() instead
*/
GThread *
g_thread_create (GThreadFunc func,
gpointer data,
gboolean joinable,
GError **error)
{
return g_thread_new_internal (NULL, func, data, joinable, 0, g_enumerable_thread_add, error);
}
/**
* g_thread_create_full:
* @func: a function to execute in the new thread.
* @data: an argument to supply to the new thread.
* @stack_size: a stack size for the new thread.
* @joinable: should this thread be joinable?
* @bound: ignored
* @priority: ignored
* @error: return location for error.
* @Returns: the new #GThread on success.
*
* 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.
*/
GThread *
g_thread_create_full (GThreadFunc func,
gpointer data,
gulong stack_size,
gboolean joinable,
gboolean bound,
GThreadPriority priority,
GError **error)
{
return g_thread_new_internal (NULL, func, data, joinable, stack_size, g_enumerable_thread_add, error);
}
/* GOnce {{{1 ------------------------------------------------------------- */
gboolean

View File

@ -698,8 +698,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 +798,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 +816,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,
@ -933,7 +933,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);

View File

@ -38,6 +38,9 @@ G_BEGIN_DECLS
(memcpy (&(dest), &(src), GLIB_SIZEOF_SYSTEM_THREAD))
#endif /* GLIB_SIZEOF_SYSTEM_THREAD == SIZEOF_VOID_P */
typedef struct _GRealThread GRealThread;
typedef void (*GThreadSetup) (GRealThread *thread);
G_GNUC_INTERNAL void g_system_thread_self (gpointer thread);
G_GNUC_INTERNAL void g_system_thread_join (gpointer thread);
G_GNUC_INTERNAL void g_system_thread_create (GThreadFunc func,
@ -52,21 +55,20 @@ G_GNUC_INTERNAL gboolean g_system_thread_equal (gpointer thread1,
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 func,
gpointer data,
gboolean joinable,
gsize stack_size,
gboolean enumerable,
GError **error);
G_GNUC_INTERNAL GThread *g_thread_new_internal (const gchar *name,
GThreadFunc func,
gpointer data,
gboolean joinable,
gsize stack_size,
GThreadSetup setup_func,
GError **error);
typedef struct _GRealThread GRealThread;
struct _GRealThread
{
GThread thread;
GRealThread *next;
const gchar *name;
gboolean enumerable;
GThreadSetup setup_func;
gpointer retval;
GSystemThread system_thread;
};
@ -74,8 +76,6 @@ struct _GRealThread
G_GNUC_INTERNAL extern GSystemThread zero_thread;
G_GNUC_INTERNAL extern GMutex g_once_mutex;
G_GNUC_INTERNAL void g_enumerable_thread_add (GRealThread *thread);
/* initializers that may also use g_private_new() */
G_GNUC_INTERNAL void _g_messages_thread_init_nomessage (void);