[glib] GRand: remove setup from g_thread_init_glib
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] GRand: remove setup from g_thread_init_glib
- Date: Fri, 9 Sep 2011 17:31:58 +0000 (UTC)
commit 71c72d5e13748c2a7e0fd52c5693240aed808238
Author: Ryan Lortie <desrt desrt ca>
Date: Fri Sep 9 13:31:21 2011 -0400
GRand: remove setup from g_thread_init_glib
Use g_once_init_enter instead.
glib/grand.c | 17 ++++-------------
glib/gthread.c | 1 -
glib/gthreadprivate.h | 1 -
3 files changed, 4 insertions(+), 15 deletions(-)
---
diff --git a/glib/grand.c b/glib/grand.c
index bb1bffe..1e50edd 100644
--- a/glib/grand.c
+++ b/glib/grand.c
@@ -130,10 +130,10 @@ static GRand* global_random = NULL;
static guint
get_random_version (void)
{
- static gboolean initialized = FALSE;
+ static gsize initialized = FALSE;
static guint random_version;
-
- if (!initialized)
+
+ if (g_once_init_enter (&initialized))
{
const gchar *version_string = g_getenv ("G_RANDOM_VERSION");
if (!version_string || version_string[0] == '\000' ||
@@ -147,21 +147,12 @@ get_random_version (void)
version_string);
random_version = 22;
}
- initialized = TRUE;
+ g_once_init_leave (&initialized, TRUE);
}
return random_version;
}
-/* This is called from g_thread_init(). It's used to
- * initialize some static data in a threadsafe way.
- */
-void
-_g_rand_thread_init (void)
-{
- (void)get_random_version ();
-}
-
struct _GRand
{
guint32 mt[N]; /* the array for the state vector */
diff --git a/glib/gthread.c b/glib/gthread.c
index 6edec63..be9a1cc 100644
--- a/glib/gthread.c
+++ b/glib/gthread.c
@@ -960,7 +960,6 @@ g_thread_init_glib (void)
/* we may run full-fledged initializers from here */
_g_convert_thread_init ();
- _g_rand_thread_init ();
_g_main_thread_init ();
_g_utils_thread_init ();
}
diff --git a/glib/gthreadprivate.h b/glib/gthreadprivate.h
index 8ee465b..70a85bc 100644
--- a/glib/gthreadprivate.h
+++ b/glib/gthreadprivate.h
@@ -54,7 +54,6 @@ G_GNUC_INTERNAL void _g_messages_thread_init_nomessage (void);
/* full fledged initializers */
G_GNUC_INTERNAL void _g_convert_thread_init (void);
-G_GNUC_INTERNAL void _g_rand_thread_init (void);
G_GNUC_INTERNAL void _g_main_thread_init (void);
G_GNUC_INTERNAL void _g_atomic_thread_init (void);
G_GNUC_INTERNAL void _g_utils_thread_init (void);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]