Deprecate g_thread_create_full()

Replace it with g_thread_create_with_stack_size() and a real function
implementation of g_thread_create().

Modify a testcase that was calling g_thread_create_full()
inappropriately (it was using the default values anyway).
This commit is contained in:
Ryan Lortie 2011-09-19 00:45:19 -04:00
parent 9621b1093e
commit 14e6377a60
5 changed files with 68 additions and 20 deletions

View File

@ -595,6 +595,7 @@ GThreadFunc
GThreadPriority
GThread
g_thread_create
g_thread_create_with_stack_size
g_thread_create_full
g_thread_self
g_thread_join

View File

@ -1092,6 +1092,8 @@ g_thread_functions_for_glib_use
g_threads_got_initialized
g_thread_use_default_impl
g_thread_gettime
g_thread_create
g_thread_create_with_stack_size
g_thread_create_full
g_thread_error_quark
g_thread_exit

View File

@ -1669,15 +1669,21 @@ g_thread_create_proxy (gpointer data)
*
* Returns: the new #GThread on success
*/
GThread *
g_thread_create (GThreadFunc func,
gpointer data,
gboolean joinable,
GError **error)
{
return g_thread_create_with_stack_size (func, data, joinable, 0, error);
}
/**
* g_thread_create_full:
* g_thread_create_with_stack_size:
* @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
* @stack_size: a stack size for the new thread.
* @error: return location for error.
* @Returns: the new #GThread on success.
*
@ -1696,19 +1702,19 @@ g_thread_create_proxy (gpointer data)
* @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.
*
* <note><para>Only use g_thread_create_full() if you really can't use
* g_thread_create() instead. g_thread_create() does not take
* @stack_size, @bound, and @priority as arguments, as they should only
* be used in cases in which it is unavoidable.</para></note>
* <note><para>
* Only use g_thread_create_with_stack_size() if you really can't use
* g_thread_create() instead. g_thread_create() does not take
* @stack_size, as it should only be used in cases in which it is
* unavoidable.
* </para></note>
**/
GThread*
g_thread_create_full (GThreadFunc func,
gpointer data,
gulong stack_size,
gboolean joinable,
gboolean bound,
GThreadPriority priority,
GError **error)
g_thread_create_with_stack_size (GThreadFunc func,
gpointer data,
gboolean joinable,
gsize stack_size,
GError **error)
{
GRealThread* result;
GError *local_error = NULL;
@ -1741,6 +1747,34 @@ g_thread_create_full (GThreadFunc func,
return (GThread*) result;
}
/**
* 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_create() or g_thread_create_with_stack_size() instead.
**/
GThread *
g_thread_create_full (GThreadFunc func,
gpointer data,
gulong stack_size,
gboolean joinable,
gboolean bound,
GThreadPriority priority,
GError **error)
{
return g_thread_create_with_stack_size (func, data, joinable, stack_size, error);
}
/**
* g_thread_exit:
* @retval: the return value of this thread.

View File

@ -174,9 +174,7 @@ GMutex* g_static_mutex_get_mutex_impl (GMutex **mutex);
#define g_thread_supported() (g_threads_got_initialized)
#endif
#define g_thread_create(func, data, joinable, error) \
(g_thread_create_full (func, data, 0, joinable, FALSE, 0, error))
#ifndef G_DISABLE_DEPRECATED
GThread* g_thread_create_full (GThreadFunc func,
gpointer data,
gulong stack_size,
@ -184,6 +182,19 @@ GThread* g_thread_create_full (GThreadFunc func,
gboolean bound,
GThreadPriority priority,
GError **error);
#endif
GThread * g_thread_create (GThreadFunc func,
gpointer data,
gboolean joinable,
GError **error);
GThread * g_thread_create_with_stack_size (GThreadFunc func,
gpointer data,
gboolean joinable,
gsize stack_size,
GError **error);
GThread* g_thread_self (void);
void g_thread_exit (gpointer retval);
gpointer g_thread_join (GThread *thread);

View File

@ -282,12 +282,12 @@ main (int argc,
threads = g_alloca (sizeof(GThread*) * n_threads);
if (!use_memchunks)
for (i = 0; i < n_threads; i++)
threads[i] = g_thread_create_full (test_sliced_mem_thread, seedp, 0, TRUE, FALSE, 0, NULL);
threads[i] = g_thread_create (test_sliced_mem_thread, seedp, TRUE, NULL);
else
{
old_mem_chunks_init();
for (i = 0; i < n_threads; i++)
threads[i] = g_thread_create_full (test_memchunk_thread, seedp, 0, TRUE, FALSE, 0, NULL);
threads[i] = g_thread_create (test_memchunk_thread, seedp, TRUE, NULL);
}
for (i = 0; i < n_threads; i++)
g_thread_join (threads[i]);