mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
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.
This commit is contained in:
parent
2c7388c19a
commit
cf26a6fc32
@ -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);
|
||||
|
@ -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 */
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user