[glib] G_LOCK: port from GStaticMutex to GMutex



commit cf26a6fc32e32bd71d4652245257477ae34d9a15
Author: Ryan Lortie <desrt desrt ca>
Date:   Sat Sep 17 18:33:25 2011 -0400

    G_LOCK: port from GStaticMutex to GMutex
    
    GCancellable made use of the undocumented G_LOCK_NAME macro in an
    invalid way.  Fix that up while we're at it.

 gio/gcancellable.c |    6 ++----
 glib/gthread.h     |   16 ++++++++--------
 2 files changed, 10 insertions(+), 12 deletions(-)
---
diff --git a/gio/gcancellable.c b/gio/gcancellable.c
index 91ff249..7ebbdf4 100644
--- a/gio/gcancellable.c
+++ b/gio/gcancellable.c
@@ -270,8 +270,7 @@ g_cancellable_reset (GCancellable *cancellable)
   while (priv->cancelled_running)
     {
       priv->cancelled_running_waiting = TRUE;
-      g_cond_wait (cancellable_cond,
-                   g_static_mutex_get_mutex (& G_LOCK_NAME (cancellable)));
+      g_cond_wait (cancellable_cond, &G_LOCK_NAME (cancellable));
     }
 
   if (priv->cancelled)
@@ -619,8 +618,7 @@ g_cancellable_disconnect (GCancellable  *cancellable,
   while (priv->cancelled_running)
     {
       priv->cancelled_running_waiting = TRUE;
-      g_cond_wait (cancellable_cond,
-                   g_static_mutex_get_mutex (& G_LOCK_NAME (cancellable)));
+      g_cond_wait (cancellable_cond, &G_LOCK_NAME (cancellable));
     }
 
   g_signal_handler_disconnect (cancellable, handler_id);
diff --git a/glib/gthread.h b/glib/gthread.h
index 68d808d..6b7b7b6 100644
--- a/glib/gthread.h
+++ b/glib/gthread.h
@@ -348,8 +348,8 @@ extern void glib_dummy_decl (void);
 #define G_LOCK_NAME(name)               g__ ## name ## _lock
 #define G_LOCK_DEFINE_STATIC(name)    static G_LOCK_DEFINE (name)
 #define G_LOCK_DEFINE(name)           \
-  GStaticMutex G_LOCK_NAME (name) = G_STATIC_MUTEX_INIT
-#define G_LOCK_EXTERN(name)           extern GStaticMutex G_LOCK_NAME (name)
+  GMutex G_LOCK_NAME (name) = G_MUTEX_INIT
+#define G_LOCK_EXTERN(name)           extern GMutex G_LOCK_NAME (name)
 
 #ifdef G_DEBUG_LOCKS
 #  define G_LOCK(name)                G_STMT_START{             \
@@ -357,24 +357,24 @@ extern void glib_dummy_decl (void);
              "file %s: line %d (%s): locking: %s ",             \
              __FILE__,        __LINE__, G_STRFUNC,              \
              #name);                                            \
-      g_static_mutex_lock (&G_LOCK_NAME (name));                \
+      g_mutex_lock (&G_LOCK_NAME (name));                       \
    }G_STMT_END
 #  define G_UNLOCK(name)              G_STMT_START{             \
       g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,                   \
              "file %s: line %d (%s): unlocking: %s ",           \
              __FILE__,        __LINE__, G_STRFUNC,              \
              #name);                                            \
-     g_static_mutex_unlock (&G_LOCK_NAME (name));               \
+     g_mutex_unlock (&G_LOCK_NAME (name));                      \
    }G_STMT_END
 #  define G_TRYLOCK(name)                                       \
       (g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,                  \
              "file %s: line %d (%s): try locking: %s ",         \
              __FILE__,        __LINE__, G_STRFUNC,              \
-             #name), g_static_mutex_trylock (&G_LOCK_NAME (name)))
+             #name), g_mutex_trylock (&G_LOCK_NAME (name)))
 #else  /* !G_DEBUG_LOCKS */
-#  define G_LOCK(name) g_static_mutex_lock       (&G_LOCK_NAME (name))
-#  define G_UNLOCK(name) g_static_mutex_unlock   (&G_LOCK_NAME (name))
-#  define G_TRYLOCK(name) g_static_mutex_trylock (&G_LOCK_NAME (name))
+#  define G_LOCK(name) g_mutex_lock       (&G_LOCK_NAME (name))
+#  define G_UNLOCK(name) g_mutex_unlock   (&G_LOCK_NAME (name))
+#  define G_TRYLOCK(name) g_mutex_trylock (&G_LOCK_NAME (name))
 #endif /* !G_DEBUG_LOCKS */
 
 



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