diff options
author | Ryan Lortie <desrt@desrt.ca> | 2011-10-13 00:43:33 -0400 |
---|---|---|
committer | Ryan Lortie <desrt@desrt.ca> | 2011-10-13 00:43:33 -0400 |
commit | 015f4b4513279c4be40c03121473ffcea347ed84 (patch) | |
tree | 217484a9870e1e092bb409ffb5e7f02c3114d7e1 /glib/deprecated | |
parent | b0e73ca390d0f22baccc3636dd4d2e8e9cb0f58f (diff) | |
download | glib-015f4b4513279c4be40c03121473ffcea347ed84.tar.gz |
thread: nuke the concept of 'joinable'
And remove the 'joinable' argument from g_thread_new() and
g_thread_new_full().
Change the wording in the docs. Clarify expectations for
(deprecated) g_thread_create().
Diffstat (limited to 'glib/deprecated')
-rw-r--r-- | glib/deprecated/gthread-deprecated.c | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/glib/deprecated/gthread-deprecated.c b/glib/deprecated/gthread-deprecated.c index a52e08d8c..3a0179901 100644 --- a/glib/deprecated/gthread-deprecated.c +++ b/glib/deprecated/gthread-deprecated.c @@ -312,16 +312,17 @@ g_deprecated_thread_proxy (gpointer data) * * 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. * + * This function returns a reference to the created thread only if + * @joinable is %TRUE. In that case, you must free this reference by + * calling g_thread_unref() or g_thread_join(). If @joinable is %FALSE + * then you should probably not touch the return value. + * * Returns: the new #GThread on success * * Deprecated:2.32: Use g_thread_new() instead @@ -332,7 +333,7 @@ g_thread_create (GThreadFunc func, gboolean joinable, GError **error) { - return g_thread_new_internal (NULL, g_deprecated_thread_proxy, func, data, joinable, 0, error); + return g_thread_create_full (func, data, 0, joinable, 0, 0, error); } /** @@ -360,10 +361,19 @@ g_thread_create_full (GThreadFunc func, GThreadPriority priority, GError **error) { - return g_thread_new_internal (NULL, g_deprecated_thread_proxy, func, data, joinable, stack_size, error); -} + GThread *thread; + thread = g_thread_new_internal (NULL, g_deprecated_thread_proxy, + func, data, stack_size, error); + if (!joinable) + { + thread->joinable = FALSE; + g_thread_unref (thread); + } + + return thread; +} /* GOnce {{{1 ------------------------------------------------------------- */ gboolean |