#define posix_check_cmd(cmd) posix_check_err (cmd, #cmd)
-GRealThread *
-g_system_thread_new (void)
-{
- return g_slice_new0 (GRealThread);
-}
-
void
g_system_thread_free (GRealThread *thread)
{
g_slice_free (GRealThread, thread);
}
-void
-g_system_thread_create (GThreadFunc thread_func,
- gulong stack_size,
- gboolean joinable,
- GRealThread *thread,
- GError **error)
+GRealThread *
+g_system_thread_new (GThreadFunc thread_func,
+ gulong stack_size,
+ gboolean joinable,
+ GError **error)
{
+ GRealThread *thread;
pthread_attr_t attr;
gint ret;
- g_return_if_fail (thread_func);
+ thread = g_slice_new0 (GRealThread);
posix_check_cmd (pthread_attr_init (&attr));
{
g_set_error (error, G_THREAD_ERROR, G_THREAD_ERROR_AGAIN,
"Error creating thread: %s", g_strerror (ret));
- return;
+ return thread;
}
posix_check_err (ret, "pthread_create");
+
+ return thread;
}
/**
gboolean joinable;
};
-GRealThread *
-g_system_thread_new (void)
-{
- return g_slice_new0 (GRealThread);
-}
-
void
g_system_thread_free (GRealThread *thread)
{
return 0;
}
-void
-g_system_thread_create (GThreadFunc func,
- gulong stack_size,
- gboolean joinable,
- GRealThread *thread,
- GError **error)
+GRealThread *
+g_system_thread_new (GThreadFunc func,
+ gulong stack_size,
+ gboolean joinable,
+ GError **error)
{
+ GRealThread *thread;
guint ignore;
GThreadData *retval;
- g_return_if_fail (func);
-
+ thread = g_slice_new0 (GRealThread);
retval = g_new(GThreadData, 1);
retval->func = func;
retval->data = thread;
"Error creating thread: %s", win_error);
g_free (retval);
g_free (win_error);
- return;
+ return thread;
}
*(GThreadData **) &(thread->system_thread) = retval;
+
+ return thread;
}
void
/* This has to happen before G_LOCK, as that might call g_thread_self */
g_private_set (&g_thread_specific_private, data);
- /* The lock makes sure that thread->system_thread is written,
- * before thread->thread.func is called. See g_thread_new_internal().
+ /* The lock makes sure that g_thread_new_internal() has a chance to
+ * setup 'func' and 'data' before we make the call.
*/
G_LOCK (g_thread_new);
G_UNLOCK (g_thread_new);
g_return_val_if_fail (func != NULL, NULL);
- result = g_system_thread_new ();
-
+ 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;
- G_LOCK (g_thread_new);
- g_system_thread_create (proxy, stack_size, joinable,
- result, &local_error);
G_UNLOCK (g_thread_new);
if (local_error)
typedef struct _GRealThread GRealThread;
G_GNUC_INTERNAL
-void g_system_thread_wait (GRealThread *thread);
+void g_system_thread_wait (GRealThread *thread);
G_GNUC_INTERNAL
-GRealThread * g_system_thread_new (void);
-G_GNUC_INTERNAL void g_system_thread_create (GThreadFunc func,
- gulong stack_size,
- gboolean joinable,
- GRealThread *thread,
- GError **error);
+GRealThread * g_system_thread_new (GThreadFunc func,
+ gulong stack_size,
+ gboolean joinable,
+ GError **error);
G_GNUC_INTERNAL
void g_system_thread_free (GRealThread *thread);