#include "config.h"
+/* we know we are deprecated here, no need for warnings */
+#define GLIB_DISABLE_DEPRECATION_WARNINGS
+
#include "gmessages.h"
#include "gslice.h"
#include "gmain.h"
/* {{{1 Documentation */
/**
+ * SECTION:threads-deprecated
+ * @title: Deprecated thread API
+ * @short_description: old thread APIs (for reference only)
+ * @see_also: #GThread
+ *
+ * These APIs are deprecated. You should not use them in new code.
+ * This section remains only to assist with understanding code that was
+ * written to use these APIs at some point in the past.
+ **/
+
+/**
* GThreadPriority:
* @G_THREAD_PRIORITY_LOW: a priority lower than normal
* @G_THREAD_PRIORITY_NORMAL: the default priority
/* {{{1 Exported Variables */
-gboolean g_thread_use_default_impl = TRUE;
+/* Set this FALSE to have previously-compiled GStaticMutex code use the
+ * slow path (ie: call into us) to avoid compatibility problems.
+ */
+gboolean g_thread_use_default_impl = FALSE;
GThreadFunctions g_thread_functions_for_glib_use =
{
* Deprecated: 2.32: Just use a #GMutex
*/
GMutex *
-g_static_mutex_get_mutex_impl (GMutex** mutex)
+g_static_mutex_get_mutex_impl (GStaticMutex* mutex)
{
GMutex *result;
if (!g_thread_supported ())
return NULL;
- result = g_atomic_pointer_get (mutex);
+ result = g_atomic_pointer_get (&mutex->mutex);
if (!result)
{
g_mutex_lock (&g_once_mutex);
- result = *mutex;
+ result = mutex->mutex;
if (!result)
{
result = g_mutex_new ();
- g_atomic_pointer_set (mutex, result);
+ g_atomic_pointer_set (&mutex->mutex, result);
}
g_mutex_unlock (&g_once_mutex);
GStaticPrivate *owner;
};
+void
+g_static_private_cleanup (gpointer data)
+{
+ GArray *array = data;
+ guint i;
+
+ for (i = 0; i < array->len; i++ )
+ {
+ GStaticPrivateNode *node = &g_array_index (array, GStaticPrivateNode, i);
+ if (node->destroy)
+ node->destroy (node->data);
+ }
+
+ g_array_free (array, TRUE);
+}
+
+GPrivate static_private_private = G_PRIVATE_INIT (g_static_private_cleanup);
+
/**
* GStaticPrivate:
*
gpointer
g_static_private_get (GStaticPrivate *private_key)
{
- GRealThread *self = (GRealThread*) g_thread_self ();
GArray *array;
gpointer ret = NULL;
- array = self->private_data;
+
+ array = g_private_get (&static_private_private);
if (array && private_key->index != 0 && private_key->index <= array->len)
{
gpointer data,
GDestroyNotify notify)
{
- GRealThread *self = (GRealThread*) g_thread_self ();
GArray *array;
static guint next_index = 0;
GStaticPrivateNode *node;
G_UNLOCK (g_thread);
}
- array = self->private_data;
+ array = g_private_get (&static_private_private);
if (!array)
{
array = g_array_new (FALSE, TRUE, sizeof (GStaticPrivateNode));
- self->private_data = array;
+ g_private_set (&static_private_private, array);
}
if (private_key->index > array->len)
g_array_set_size (array, private_key->index);
G_UNLOCK (g_thread);
}
-void
-g_static_private_cleanup (GRealThread *thread)
-{
- GArray *array;
-
- array = thread->private_data;
- thread->private_data = NULL;
-
- if (array)
- {
- guint i;
-
- for (i = 0; i < array->len; i++ )
- {
- GStaticPrivateNode *node = &g_array_index (array, GStaticPrivateNode, i);
- if (node->destroy)
- node->destroy (node->data);
- }
- g_array_free (array, TRUE);
- }
-}
-
/* GMutex {{{1 ------------------------------------------------------ */
/**