data->context = g_main_context_new ();
data->loop = g_main_loop_new (data->context, FALSE);
- data->thread = g_thread_create (gdbus_shared_thread_func,
- data,
- TRUE,
- &error);
+ data->thread = g_thread_new ("gdbus",
+ gdbus_shared_thread_func,
+ data,
+ TRUE,
+ &error);
g_assert_no_error (error);
/* We can cast between gsize and gpointer safely */
g_once_init_leave (&shared_thread_data, (gsize) data);
}
/**
+ * g_thread_create:
+ * @func: a function to execute in the new thread
+ * @data: an argument to supply to the new thread
+ * @joinable: should this thread be joinable?
+ * @error: return location for error, or %NULL
+ *
+ * This function creates a new thread.
+ *
+ * If @joinable is %TRUE, you can wait for this threads termination
+ * calling g_thread_join(). Otherwise the thread will just disappear
+ * when it terminates.
+ *
+ * The new thread executes the function @func with the argument @data.
+ * If the thread was created successfully, it is returned.
+ *
+ * @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.
+ *
+ * Returns: the new #GThread on success
+ *
+ * Deprecated:2.32: Use g_thread_new() instead
+ */
+GThread *
+g_thread_create (GThreadFunc func,
+ gpointer data,
+ gboolean joinable,
+ GError **error)
+{
+ return g_thread_new_full (NULL, func, data, joinable, 0, error);
+}
+
+/**
* g_thread_create_full:
* @func: a function to execute in the new thread.
* @data: an argument to supply to the new thread.
* 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.
+ * Use g_thread_new() or g_thread_new_full() instead.
*/
GThread *
g_thread_create_full (GThreadFunc func,
GThreadPriority priority,
GError **error)
{
- return g_thread_create_with_stack_size (func, data, joinable, stack_size, error);
+ return g_thread_new_full (NULL, func, data, joinable, stack_size, error);
}
/* GStaticMutex {{{1 ------------------------------------------------------ */
/* internal function for fallback static mutex implementation */
GMutex* g_static_mutex_get_mutex_impl (GMutex **mutex);
+GThread* g_thread_create (GThreadFunc func,
+ gpointer data,
+ gboolean joinable,
+ GError **error);
GThread* g_thread_create_full (GThreadFunc func,
gpointer data,
gulong stack_size,
g_once_impl
g_once_init_enter_impl
g_once_init_leave
-g_thread_init_glib
g_once_init_enter
-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
+g_thread_functions_for_glib_use
+g_thread_init_glib
g_thread_join
+g_thread_new
+g_thread_new_full
g_thread_self
g_thread_set_priority
+g_thread_use_default_impl
g_thread_yield
g_static_mutex_free
g_static_mutex_get_mutex_impl
GError *error = NULL;
glib_worker_context = g_main_context_new ();
- if (g_thread_create (glib_worker_main, NULL, FALSE, &error) == NULL)
+ if (g_thread_new ("gmain", glib_worker_main, NULL, FALSE, &error) == NULL)
g_error ("Creating GLib worker thread failed: %s\n", error->message);
g_once_init_leave (&initialised, TRUE);
GThread thread;
GArray *private_data;
GRealThread *next;
+ const gchar *name;
gpointer retval;
GSystemThread system_thread;
};
}
}
G_UNLOCK (g_thread);
-
/* Just to make sure, this isn't used any more */
g_system_thread_assign (thread->system_thread, zero_thread);
g_free (thread);
}
/**
- * g_thread_create:
+ * g_thread_new:
+ * @name: a name for the new thread
* @func: a function to execute in the new thread
* @data: an argument to supply to the new thread
* @joinable: should this thread be joinable?
- * @error: return location for error, or %NULL
+ * @error: return location for error
*
* This function creates a new thread.
*
+ * The @name can be useful for discriminating threads in
+ * a debugger. Some systems restrict the length of @name to
+ * 16 bytes.
+ *
* If @joinable is %TRUE, you can wait for this threads termination
* calling g_thread_join(). Otherwise the thread will just disappear
* when it terminates.
* The error is set, if and only if the function returns %NULL.
*
* Returns: the new #GThread on success
+ *
+ * Since: 2.32
*/
GThread *
-g_thread_create (GThreadFunc func,
- gpointer data,
- gboolean joinable,
- GError **error)
+g_thread_new (const gchar *name,
+ GThreadFunc func,
+ gpointer data,
+ gboolean joinable,
+ GError **error)
{
- return g_thread_create_with_stack_size (func, data, joinable, 0, error);
+ return g_thread_new_full (name, func, data, joinable, 0, error);
}
/**
- * g_thread_create_with_stack_size:
+ * g_thread_new_full:
+ * @name: a name for the new thread
* @func: a function to execute in the new thread
* @data: an argument to supply to the new thread
* @joinable: should this thread be joinable?
* @stack_size: a stack size for the new thread
* @error: return location for error
*
- * This function creates a new thread. If the underlying thread
- * implementation supports it, the thread gets a stack size of
- * @stack_size or the default value for the current platform, if
- * @stack_size is 0.
+ * This function creates a new thread.
+ *
+ * The @name can be useful for discriminating threads in
+ * a debugger. Some systems restrict the length of @name to
+ * 16 bytes.
+ *
+ * If the underlying thread implementation supports it, the thread
+ * gets a stack size of @stack_size or the default value for the
+ * current platform, if @stack_size is 0.
*
* If @joinable is %TRUE, you can wait for this threads termination
* calling g_thread_join(). Otherwise the thread will just disappear
* @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_with_stack_size() if you
- * really can't use g_thread_create() instead. g_thread_create()
+ * <note><para>Only use a non-zero @stack_size if you
+ * really can't use the default instead. g_thread_new()
* does not take @stack_size, as it should only be used in cases
* in which it is unavoidable.</para></note>
*
*
* Since: 2.32
*/
-GThread*
-g_thread_create_with_stack_size (GThreadFunc func,
- gpointer data,
- gboolean joinable,
- gsize stack_size,
- GError **error)
+GThread *
+g_thread_new_full (const gchar *name,
+ GThreadFunc func,
+ gpointer data,
+ gboolean joinable,
+ gsize stack_size,
+ GError **error)
{
GRealThread* result;
GError *local_error = NULL;
result->thread.func = func;
result->thread.data = data;
result->private_data = NULL;
+ result->name = name;
G_LOCK (g_thread);
g_system_thread_create (g_thread_create_proxy, result,
stack_size, joinable,
}
}
G_UNLOCK (g_thread);
-
/* Just to make sure, this isn't used any more */
thread->joinable = 0;
g_system_thread_assign (real->system_thread, zero_thread);
GMutex* g_static_mutex_get_mutex_impl (GMutex **mutex);
-GThread *g_thread_create (GThreadFunc func,
+GThread *g_thread_new (const gchar *name,
+ GThreadFunc func,
gpointer data,
gboolean joinable,
GError **error);
-GThread *g_thread_create_with_stack_size (GThreadFunc func,
+GThread *g_thread_new_full (const gchar *name,
+ GThreadFunc func,
gpointer data,
gboolean joinable,
gsize stack_size,
GError *local_error = NULL;
/* No thread was found, we have to start a new one */
- if (!g_thread_create (g_thread_pool_thread_proxy, pool, FALSE, &local_error))
+ if (!g_thread_new ("pool", g_thread_pool_thread_proxy, pool, FALSE, &local_error))
{
g_propagate_error (error, local_error);
return FALSE;