[glib] thread: stop sharing g_once_mutex
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] thread: stop sharing g_once_mutex
- Date: Thu, 13 Oct 2011 01:48:26 +0000 (UTC)
commit d537726ded76eb470a78d41418579b8652c4ae8b
Author: Ryan Lortie <desrt desrt ca>
Date: Wed Oct 12 21:47:25 2011 -0400
thread: stop sharing g_once_mutex
Unrelated code shouldn't be sharing the same mutex for no good reason --
particularly not across a file boundary.
glib/deprecated/gthread-deprecated.c | 9 +++++----
glib/gthread.c | 2 +-
glib/gthreadprivate.h | 2 --
3 files changed, 6 insertions(+), 7 deletions(-)
---
diff --git a/glib/deprecated/gthread-deprecated.c b/glib/deprecated/gthread-deprecated.c
index 1e99694..a52e08d 100644
--- a/glib/deprecated/gthread-deprecated.c
+++ b/glib/deprecated/gthread-deprecated.c
@@ -199,6 +199,7 @@ static GSList *g_thread_all_threads = NULL;
static GSList *g_thread_free_indices = NULL;
/* Protects g_thread_all_threads and g_thread_free_indices */
+G_LOCK_DEFINE_STATIC (g_static_mutex);
G_LOCK_DEFINE_STATIC (g_thread);
/* Misc. GThread functions {{{1 */
@@ -504,7 +505,7 @@ g_static_mutex_get_mutex_impl (GStaticMutex* mutex)
if (!result)
{
- g_mutex_lock (&g_once_mutex);
+ G_LOCK (g_static_mutex);
result = mutex->mutex;
if (!result)
@@ -513,7 +514,7 @@ g_static_mutex_get_mutex_impl (GStaticMutex* mutex)
g_atomic_pointer_set (&mutex->mutex, result);
}
- g_mutex_unlock (&g_once_mutex);
+ G_UNLOCK (g_static_mutex);
}
return result;
@@ -660,7 +661,7 @@ g_static_rec_mutex_get_rec_mutex_impl (GStaticRecMutex* mutex)
if (!result)
{
- g_mutex_lock (&g_once_mutex);
+ G_LOCK (g_static_mutex);
result = (GRecMutex *) mutex->mutex.mutex;
if (!result)
@@ -670,7 +671,7 @@ g_static_rec_mutex_get_rec_mutex_impl (GStaticRecMutex* mutex)
g_atomic_pointer_set (&mutex->mutex.mutex, result);
}
- g_mutex_unlock (&g_once_mutex);
+ G_UNLOCK (g_static_mutex);
}
return result;
diff --git a/glib/gthread.c b/glib/gthread.c
index 27cdc08..18db89f 100644
--- a/glib/gthread.c
+++ b/glib/gthread.c
@@ -468,7 +468,7 @@ g_thread_error_quark (void)
/* Local Data {{{1 -------------------------------------------------------- */
-GMutex g_once_mutex;
+static GMutex g_once_mutex;
static GCond g_once_cond;
static GSList *g_once_init_list = NULL;
diff --git a/glib/gthreadprivate.h b/glib/gthreadprivate.h
index 3aebf72..5ade4a3 100644
--- a/glib/gthreadprivate.h
+++ b/glib/gthreadprivate.h
@@ -61,8 +61,6 @@ struct _GRealThread
GSystemThread system_thread;
};
-G_GNUC_INTERNAL extern GMutex g_once_mutex;
-
#ifdef G_OS_WIN32
G_GNUC_INTERNAL void g_thread_DllMain (void);
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]