[glib] gslice: remove single-threaded case
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gslice: remove single-threaded case
- Date: Thu, 22 Sep 2011 00:23:39 +0000 (UTC)
commit af9e40dc5def1352e01368de56577addb2c7bbc1
Author: Ryan Lortie <desrt desrt ca>
Date: Wed Sep 21 20:13:57 2011 -0400
gslice: remove single-threaded case
GPrivate always works, so use it normally at all times.
glib/gslice.c | 35 ++++-------------------------------
1 files changed, 4 insertions(+), 31 deletions(-)
---
diff --git a/glib/gslice.c b/glib/gslice.c
index 05b4a5a..7ee43f0 100644
--- a/glib/gslice.c
+++ b/glib/gslice.c
@@ -419,38 +419,11 @@ thread_memory_from_self (void)
ThreadMemory *tmem = g_private_get (&private_thread_memory);
if (G_UNLIKELY (!tmem))
{
- static ThreadMemory *single_thread_memory = NULL; /* remember single-thread info for multi-threaded case */
- if (single_thread_memory && g_thread_supported ())
- {
- g_mutex_lock (&allocator->slab_mutex);
- if (single_thread_memory)
- {
- /* GSlice has been used before g_thread_init(), and now
- * we are running threaded. to cope with it, use the saved
- * thread memory structure from when we weren't threaded.
- */
- tmem = single_thread_memory;
- single_thread_memory = NULL; /* slab_mutex protected when multi-threaded */
- }
- g_mutex_unlock (&allocator->slab_mutex);
- }
- if (!tmem)
- {
- const guint n_magazines = MAX_SLAB_INDEX (allocator);
- tmem = g_malloc0 (sizeof (ThreadMemory) + sizeof (Magazine) * 2 * n_magazines);
- tmem->magazine1 = (Magazine*) (tmem + 1);
- tmem->magazine2 = &tmem->magazine1[n_magazines];
- }
- /* g_private_get/g_private_set works in the single-threaded xor the multi-
- * threaded case. but not *across* g_thread_init(), after multi-thread
- * initialization it returns NULL for previously set single-thread data.
- */
+ const guint n_magazines = MAX_SLAB_INDEX (allocator);
+ tmem = g_malloc0 (sizeof (ThreadMemory) + sizeof (Magazine) * 2 * n_magazines);
+ tmem->magazine1 = (Magazine*) (tmem + 1);
+ tmem->magazine2 = &tmem->magazine1[n_magazines];
g_private_set (&private_thread_memory, tmem);
- /* save single-thread thread memory structure, in case we need to
- * pick it up again after multi-thread initialization happened.
- */
- if (!single_thread_memory && !g_thread_supported ())
- single_thread_memory = tmem; /* no slab_mutex created yet */
}
return tmem;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]