mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-20 15:48:54 +02:00
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.
This commit is contained in:
@@ -199,6 +199,7 @@ static GSList *g_thread_all_threads = NULL;
|
|||||||
static GSList *g_thread_free_indices = NULL;
|
static GSList *g_thread_free_indices = NULL;
|
||||||
|
|
||||||
/* Protects g_thread_all_threads and g_thread_free_indices */
|
/* Protects g_thread_all_threads and g_thread_free_indices */
|
||||||
|
G_LOCK_DEFINE_STATIC (g_static_mutex);
|
||||||
G_LOCK_DEFINE_STATIC (g_thread);
|
G_LOCK_DEFINE_STATIC (g_thread);
|
||||||
|
|
||||||
/* Misc. GThread functions {{{1 */
|
/* Misc. GThread functions {{{1 */
|
||||||
@@ -504,7 +505,7 @@ g_static_mutex_get_mutex_impl (GStaticMutex* mutex)
|
|||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
g_mutex_lock (&g_once_mutex);
|
G_LOCK (g_static_mutex);
|
||||||
|
|
||||||
result = mutex->mutex;
|
result = mutex->mutex;
|
||||||
if (!result)
|
if (!result)
|
||||||
@@ -513,7 +514,7 @@ g_static_mutex_get_mutex_impl (GStaticMutex* mutex)
|
|||||||
g_atomic_pointer_set (&mutex->mutex, result);
|
g_atomic_pointer_set (&mutex->mutex, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_mutex_unlock (&g_once_mutex);
|
G_UNLOCK (g_static_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -660,7 +661,7 @@ g_static_rec_mutex_get_rec_mutex_impl (GStaticRecMutex* mutex)
|
|||||||
|
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
g_mutex_lock (&g_once_mutex);
|
G_LOCK (g_static_mutex);
|
||||||
|
|
||||||
result = (GRecMutex *) mutex->mutex.mutex;
|
result = (GRecMutex *) mutex->mutex.mutex;
|
||||||
if (!result)
|
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_atomic_pointer_set (&mutex->mutex.mutex, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_mutex_unlock (&g_once_mutex);
|
G_UNLOCK (g_static_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@@ -468,7 +468,7 @@ g_thread_error_quark (void)
|
|||||||
|
|
||||||
/* Local Data {{{1 -------------------------------------------------------- */
|
/* Local Data {{{1 -------------------------------------------------------- */
|
||||||
|
|
||||||
GMutex g_once_mutex;
|
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;
|
||||||
|
|
||||||
|
@@ -61,8 +61,6 @@ struct _GRealThread
|
|||||||
GSystemThread system_thread;
|
GSystemThread system_thread;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_GNUC_INTERNAL extern GMutex g_once_mutex;
|
|
||||||
|
|
||||||
#ifdef G_OS_WIN32
|
#ifdef G_OS_WIN32
|
||||||
G_GNUC_INTERNAL void g_thread_DllMain (void);
|
G_GNUC_INTERNAL void g_thread_DllMain (void);
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user