thread creation: Simplify error handling

Instead of always returning non-NULL and finding out about errors via
the GError*, return NULL from the backend in the event of an error.
This commit is contained in:
Ryan Lortie
2011-10-12 22:35:35 -04:00
parent e14a3746db
commit 2f5486f020
3 changed files with 15 additions and 18 deletions

View File

@@ -799,27 +799,22 @@ g_thread_new_internal (const gchar *name,
gsize stack_size,
GError **error)
{
GRealThread *result;
GError *local_error = NULL;
GRealThread *thread;
g_return_val_if_fail (func != NULL, NULL);
G_LOCK (g_thread_new);
result = g_system_thread_new (proxy, stack_size, joinable, &local_error);
result->thread.joinable = joinable;
result->thread.func = func;
result->thread.data = data;
result->name = name;
thread = g_system_thread_new (proxy, stack_size, joinable, error);
if (thread)
{
thread->thread.joinable = joinable;
thread->thread.func = func;
thread->thread.data = data;
thread->name = name;
}
G_UNLOCK (g_thread_new);
if (local_error)
{
g_propagate_error (error, local_error);
g_system_thread_free (result);
return NULL;
}
return (GThread*) result;
return (GThread*) thread;
}
/**