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

@@ -104,7 +104,7 @@ test_once3 (void)
shared = 0;
for (i = 0; i < THREADS; i++)
threads[i] = g_thread_new ("once3", thread_func, NULL, NULL);
threads[i] = g_thread_new ("once3", thread_func, NULL);
for (i = 0; i < THREADS; i++)
g_thread_join (threads[i]);

View File

@@ -50,7 +50,7 @@ test_thread1 (void)
GThread *thread;
GError *error = NULL;
thread = g_thread_new ("test", thread1_func, NULL, &error);
thread = g_thread_try ("test", thread1_func, NULL, &error);
g_assert_no_error (error);
result = g_thread_join (thread);
@@ -71,7 +71,7 @@ test_thread2 (void)
gpointer result;
GThread *thread;
thread = g_thread_new ("test", thread2_func, NULL, NULL);
thread = g_thread_new ("test", thread2_func, NULL);
g_assert (g_thread_self () != thread);
@@ -135,7 +135,7 @@ test_thread4 (void)
g_error ("prlimit failed: %s\n", g_strerror (ret));
error = NULL;
thread = g_thread_new ("a", thread1_func, NULL, &error);
thread = g_thread_try ("a", thread1_func, NULL, &error);
g_assert (thread == NULL);
g_assert_error (error, G_THREAD_ERROR, G_THREAD_ERROR_AGAIN);
g_error_free (error);