[glib/wip/mutexes: 10/42] GSettings: port from GStaticMutex to GMutex



commit 9ce5cb1721ed856e1042fd3027e15d6d14e29d59
Author: Ryan Lortie <desrt desrt ca>
Date:   Sat Sep 17 19:26:41 2011 -0400

    GSettings: port from GStaticMutex to GMutex

 gio/gdelayedsettingsbackend.c |   46 ++++++++++++++++++++--------------------
 gio/gsettingsbackend.c        |   18 ++++++++--------
 2 files changed, 32 insertions(+), 32 deletions(-)
---
diff --git a/gio/gdelayedsettingsbackend.c b/gio/gdelayedsettingsbackend.c
index f7ea38b..6f3c411 100644
--- a/gio/gdelayedsettingsbackend.c
+++ b/gio/gdelayedsettingsbackend.c
@@ -30,7 +30,7 @@
 struct _GDelayedSettingsBackendPrivate
 {
   GSettingsBackend *backend;
-  GStaticMutex lock;
+  GMutex lock;
   GTree *delayed;
 
   GMainContext *owner_context;
@@ -56,7 +56,7 @@ g_delayed_settings_backend_notify_unapplied (GDelayedSettingsBackend *delayed)
   GMainContext *target_context;
   GObject *target;
 
-  g_static_mutex_lock (&delayed->priv->lock);
+  g_mutex_lock (&delayed->priv->lock);
   if (delayed->priv->owner)
     {
       target_context = delayed->priv->owner_context;
@@ -67,7 +67,7 @@ g_delayed_settings_backend_notify_unapplied (GDelayedSettingsBackend *delayed)
       target_context = NULL;
       target = NULL;
     }
-  g_static_mutex_unlock (&delayed->priv->lock);
+  g_mutex_unlock (&delayed->priv->lock);
 
   if (target != NULL)
     g_main_context_invoke (target_context, invoke_notify_unapplied, target);
@@ -85,7 +85,7 @@ g_delayed_settings_backend_read (GSettingsBackend   *backend,
 
   if (!default_value)
     {
-      g_static_mutex_lock (&delayed->priv->lock);
+      g_mutex_lock (&delayed->priv->lock);
       if (g_tree_lookup_extended (delayed->priv->delayed, key, NULL, &result))
         {
           /* NULL in the tree means we should consult the default value */
@@ -94,7 +94,7 @@ g_delayed_settings_backend_read (GSettingsBackend   *backend,
           else
             default_value = TRUE;
         }
-      g_static_mutex_unlock (&delayed->priv->lock);
+      g_mutex_unlock (&delayed->priv->lock);
     }
 
   if (result == NULL)
@@ -113,11 +113,11 @@ g_delayed_settings_backend_write (GSettingsBackend *backend,
   GDelayedSettingsBackend *delayed = G_DELAYED_SETTINGS_BACKEND (backend);
   gboolean was_empty;
 
-  g_static_mutex_lock (&delayed->priv->lock);
+  g_mutex_lock (&delayed->priv->lock);
   was_empty = g_tree_nnodes (delayed->priv->delayed) == 0;
   g_tree_insert (delayed->priv->delayed, g_strdup (key),
                  g_variant_ref_sink (value));
-  g_static_mutex_unlock (&delayed->priv->lock);
+  g_mutex_unlock (&delayed->priv->lock);
 
   g_settings_backend_changed (backend, key, origin_tag);
 
@@ -144,11 +144,11 @@ g_delayed_settings_backend_write_tree (GSettingsBackend *backend,
   GDelayedSettingsBackend *delayed = G_DELAYED_SETTINGS_BACKEND (backend);
   gboolean was_empty;
 
-  g_static_mutex_lock (&delayed->priv->lock);
+  g_mutex_lock (&delayed->priv->lock);
   was_empty = g_tree_nnodes (delayed->priv->delayed) == 0;
 
   g_tree_foreach (tree, add_to_tree, delayed->priv->delayed);
-  g_static_mutex_unlock (&delayed->priv->lock);
+  g_mutex_unlock (&delayed->priv->lock);
 
   g_settings_backend_changed_tree (backend, tree, origin_tag);
 
@@ -175,10 +175,10 @@ g_delayed_settings_backend_reset (GSettingsBackend *backend,
   GDelayedSettingsBackend *delayed = G_DELAYED_SETTINGS_BACKEND (backend);
   gboolean was_empty;
 
-  g_static_mutex_lock (&delayed->priv->lock);
+  g_mutex_lock (&delayed->priv->lock);
   was_empty = g_tree_nnodes (delayed->priv->delayed) == 0;
   g_tree_insert (delayed->priv->delayed, g_strdup (key), NULL);
-  g_static_mutex_unlock (&delayed->priv->lock);
+  g_mutex_unlock (&delayed->priv->lock);
 
   if (was_empty)
     g_delayed_settings_backend_notify_unapplied (delayed);
@@ -229,12 +229,12 @@ g_delayed_settings_backend_apply (GDelayedSettingsBackend *delayed)
       gboolean success;
       GTree *tmp;
 
-      g_static_mutex_lock (&delayed->priv->lock);
+      g_mutex_lock (&delayed->priv->lock);
       tmp = delayed->priv->delayed;
       delayed->priv->delayed = g_settings_backend_create_tree ();
       success = g_settings_backend_write_tree (delayed->priv->backend,
                                                tmp, delayed->priv);
-      g_static_mutex_unlock (&delayed->priv->lock);
+      g_mutex_unlock (&delayed->priv->lock);
 
       if (!success)
         g_settings_backend_changed_tree (G_SETTINGS_BACKEND (delayed),
@@ -253,10 +253,10 @@ g_delayed_settings_backend_revert (GDelayedSettingsBackend *delayed)
     {
       GTree *tmp;
 
-      g_static_mutex_lock (&delayed->priv->lock);
+      g_mutex_lock (&delayed->priv->lock);
       tmp = delayed->priv->delayed;
       delayed->priv->delayed = g_settings_backend_create_tree ();
-      g_static_mutex_unlock (&delayed->priv->lock);
+      g_mutex_unlock (&delayed->priv->lock);
       g_settings_backend_changed_tree (G_SETTINGS_BACKEND (delayed), tmp, NULL);
       g_tree_unref (tmp);
 
@@ -313,7 +313,7 @@ delayed_backend_writable_changed (GObject          *target,
   GDelayedSettingsBackend *delayed = G_DELAYED_SETTINGS_BACKEND (target);
   gboolean last_one = FALSE;
 
-  g_static_mutex_lock (&delayed->priv->lock);
+  g_mutex_lock (&delayed->priv->lock);
 
   if (g_tree_lookup (delayed->priv->delayed, key) != NULL &&
       !g_settings_backend_get_writable (delayed->priv->backend, key))
@@ -332,7 +332,7 @@ delayed_backend_writable_changed (GObject          *target,
       last_one = g_tree_nnodes (delayed->priv->delayed) == 0;
     }
 
-  g_static_mutex_unlock (&delayed->priv->lock);
+  g_mutex_unlock (&delayed->priv->lock);
 
   if (last_one)
     g_delayed_settings_backend_notify_unapplied (delayed);
@@ -371,7 +371,7 @@ delayed_backend_path_writable_changed (GObject          *target,
   gboolean last_one = FALSE;
   gsize n_keys;
 
-  g_static_mutex_lock (&delayed->priv->lock);
+  g_mutex_lock (&delayed->priv->lock);
 
   n_keys = g_tree_nnodes (delayed->priv->delayed);
 
@@ -397,7 +397,7 @@ delayed_backend_path_writable_changed (GObject          *target,
       last_one = g_tree_nnodes (delayed->priv->delayed) == 0;
     }
 
-  g_static_mutex_unlock (&delayed->priv->lock);
+  g_mutex_unlock (&delayed->priv->lock);
 
   if (last_one)
     g_delayed_settings_backend_notify_unapplied (delayed);
@@ -411,7 +411,7 @@ g_delayed_settings_backend_finalize (GObject *object)
 {
   GDelayedSettingsBackend *delayed = G_DELAYED_SETTINGS_BACKEND (object);
 
-  g_static_mutex_free (&delayed->priv->lock);
+  g_mutex_clear (&delayed->priv->lock);
   g_object_unref (delayed->priv->backend);
   g_tree_unref (delayed->priv->delayed);
 
@@ -450,7 +450,7 @@ g_delayed_settings_backend_init (GDelayedSettingsBackend *delayed)
                                  GDelayedSettingsBackendPrivate);
 
   delayed->priv->delayed = g_settings_backend_create_tree ();
-  g_static_mutex_init (&delayed->priv->lock);
+  g_mutex_init (&delayed->priv->lock);
 }
 
 static void
@@ -459,10 +459,10 @@ g_delayed_settings_backend_disown (gpointer  data,
 {
   GDelayedSettingsBackend *delayed = data;
 
-  g_static_mutex_lock (&delayed->priv->lock);
+  g_mutex_lock (&delayed->priv->lock);
   delayed->priv->owner_context = NULL;
   delayed->priv->owner = NULL;
-  g_static_mutex_unlock (&delayed->priv->lock);
+  g_mutex_unlock (&delayed->priv->lock);
 }
 
 GDelayedSettingsBackend *
diff --git a/gio/gsettingsbackend.c b/gio/gsettingsbackend.c
index 71341ce..8b4c5b8 100644
--- a/gio/gsettingsbackend.c
+++ b/gio/gsettingsbackend.c
@@ -41,7 +41,7 @@ typedef struct _GSettingsBackendWatch   GSettingsBackendWatch;
 struct _GSettingsBackendPrivate
 {
   GSettingsBackendWatch *watches;
-  GStaticMutex lock;
+  GMutex lock;
 };
 
 /* For g_settings_backend_sync_default(), we only want to actually do
@@ -156,7 +156,7 @@ g_settings_backend_watch_weak_notify (gpointer  data,
   GSettingsBackendWatch **ptr;
 
   /* search and remove */
-  g_static_mutex_lock (&backend->priv->lock);
+  g_mutex_lock (&backend->priv->lock);
   for (ptr = &backend->priv->watches; *ptr; ptr = &(*ptr)->next)
     if ((*ptr)->target == where_the_object_was)
       {
@@ -165,7 +165,7 @@ g_settings_backend_watch_weak_notify (gpointer  data,
         *ptr = tmp->next;
         g_slice_free (GSettingsBackendWatch, tmp);
 
-        g_static_mutex_unlock (&backend->priv->lock);
+        g_mutex_unlock (&backend->priv->lock);
         return;
       }
 
@@ -246,10 +246,10 @@ g_settings_backend_watch (GSettingsBackend              *backend,
   g_object_weak_ref (target, g_settings_backend_watch_weak_notify, backend);
 
   /* linked list prepend */
-  g_static_mutex_lock (&backend->priv->lock);
+  g_mutex_lock (&backend->priv->lock);
   watch->next = backend->priv->watches;
   backend->priv->watches = watch;
-  g_static_mutex_unlock (&backend->priv->lock);
+  g_mutex_unlock (&backend->priv->lock);
 }
 
 void
@@ -323,11 +323,11 @@ g_settings_backend_dispatch_signal (GSettingsBackend *backend,
    * count dropping -- so just add a reference to everything in the
    * suffix.
    */
-  g_static_mutex_lock (&backend->priv->lock);
+  g_mutex_lock (&backend->priv->lock);
   suffix = backend->priv->watches;
   for (watch = suffix; watch; watch = watch->next)
     g_object_ref (watch->target);
-  g_static_mutex_unlock (&backend->priv->lock);
+  g_mutex_unlock (&backend->priv->lock);
 
   /* The suffix is now immutable, so this is safe. */
   for (watch = suffix; watch; watch = next)
@@ -879,7 +879,7 @@ g_settings_backend_finalize (GObject *object)
 {
   GSettingsBackend *backend = G_SETTINGS_BACKEND (object);
 
-  g_static_mutex_unlock (&backend->priv->lock);
+  g_mutex_clear (&backend->priv->lock);
 
   G_OBJECT_CLASS (g_settings_backend_parent_class)
     ->finalize (object);
@@ -897,7 +897,7 @@ g_settings_backend_init (GSettingsBackend *backend)
   backend->priv = G_TYPE_INSTANCE_GET_PRIVATE (backend,
                                                G_TYPE_SETTINGS_BACKEND,
                                                GSettingsBackendPrivate);
-  g_static_mutex_init (&backend->priv->lock);
+  g_mutex_init (&backend->priv->lock);
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]