g_thread_new: never fail

Remove the GError argument from g_thread_new() and abort on failure.
Introduce g_thread_try() for those who want to handle failure.
This commit is contained in:
Ryan Lortie
2011-10-13 01:00:57 -04:00
parent 015f4b4513
commit 430c5635f2
26 changed files with 73 additions and 87 deletions

View File

@@ -133,8 +133,7 @@ testcase (gconstpointer data)
for (i = 0; i < THREADS; i++)
threads[i] = g_thread_new ("foo", thread_func,
GINT_TO_POINTER (use_pointers),
NULL);
GINT_TO_POINTER (use_pointers));
for (i = 0; i < THREADS; i++)
g_thread_join (threads[i]);

View File

@@ -47,7 +47,7 @@ test_atomic (void)
bucket[i] = 0;
for (i = 0; i < THREADS; i++)
threads[i] = g_thread_new ("atomic", thread_func, GINT_TO_POINTER (i), NULL);
threads[i] = g_thread_new ("atomic", thread_func, GINT_TO_POINTER (i));
for (i = 0; i < THREADS; i++)
g_thread_join (threads[i]);

View File

@@ -229,7 +229,7 @@ test_threaded (void)
for (i = 0; i < NUM_THREADS; i++)
{
context_init (&contexts[i]);
threads[i] = g_thread_new ("test", thread_func, &contexts[i], NULL);
threads[i] = g_thread_new ("test", thread_func, &contexts[i]);
}
/* dispatch tokens */

View File

@@ -34,18 +34,16 @@ static void
multithreaded_test_run (GThreadFunc function)
{
int i;
GError *error = NULL;
GPtrArray *threads = g_ptr_array_new ();
for (i = 0; i < N_THREADS; i++)
{
GThread *thread;
thread = g_thread_new ("test", function, GINT_TO_POINTER (i), &error);
g_assert_no_error (error);
thread = g_thread_new ("test", function, GINT_TO_POINTER (i));
g_ptr_array_add (threads, thread);
}
for (i = 0; i < N_THREADS; i++)
{
gpointer ret;