mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 07:26:15 +01:00
gthread: Count how many threads have been started
This will be used in a following commit to warn if setenv() is used after another thread has been created. Signed-off-by: Philip Withnall <withnall@endlessm.com> Helps: #715
This commit is contained in:
parent
5d32b99d0c
commit
6271b5eb93
@ -512,6 +512,8 @@ static GMutex g_once_mutex;
|
|||||||
static GCond g_once_cond;
|
static GCond g_once_cond;
|
||||||
static GSList *g_once_init_list = NULL;
|
static GSList *g_once_init_list = NULL;
|
||||||
|
|
||||||
|
static volatile guint g_thread_n_created_counter = 0;
|
||||||
|
|
||||||
static void g_thread_cleanup (gpointer data);
|
static void g_thread_cleanup (gpointer data);
|
||||||
static GPrivate g_thread_specific_private = G_PRIVATE_INIT (g_thread_cleanup);
|
static GPrivate g_thread_specific_private = G_PRIVATE_INIT (g_thread_cleanup);
|
||||||
|
|
||||||
@ -807,6 +809,12 @@ g_thread_proxy (gpointer data)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
guint
|
||||||
|
g_thread_n_created (void)
|
||||||
|
{
|
||||||
|
return g_atomic_int_get (&g_thread_n_created_counter);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* g_thread_new:
|
* g_thread_new:
|
||||||
* @name: (nullable): an (optional) name for the new thread
|
* @name: (nullable): an (optional) name for the new thread
|
||||||
@ -898,6 +906,8 @@ g_thread_new_internal (const gchar *name,
|
|||||||
{
|
{
|
||||||
g_return_val_if_fail (func != NULL, NULL);
|
g_return_val_if_fail (func != NULL, NULL);
|
||||||
|
|
||||||
|
g_atomic_int_inc (&g_thread_n_created_counter);
|
||||||
|
|
||||||
return (GThread *) g_system_thread_new (proxy, stack_size, scheduler_settings,
|
return (GThread *) g_system_thread_new (proxy, stack_size, scheduler_settings,
|
||||||
name, func, data, error);
|
name, func, data, error);
|
||||||
}
|
}
|
||||||
|
@ -81,6 +81,8 @@ gboolean g_thread_get_scheduler_settings (GThreadSchedulerSettings *scheduler_se
|
|||||||
|
|
||||||
gpointer g_thread_proxy (gpointer thread);
|
gpointer g_thread_proxy (gpointer thread);
|
||||||
|
|
||||||
|
guint g_thread_n_created (void);
|
||||||
|
|
||||||
gpointer g_private_set_alloc0 (GPrivate *key,
|
gpointer g_private_set_alloc0 (GPrivate *key,
|
||||||
gsize size);
|
gsize size);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user