G_DEFINE_TYPE (GCancellable, g_cancellable, G_TYPE_OBJECT);
static GPrivate current_cancellable;
-G_LOCK_DEFINE_STATIC(cancellable);
-static GCond *cancellable_cond = NULL;
+static GMutex cancellable_mutex;
+static GCond cancellable_cond;
static void
g_cancellable_finalize (GObject *object)
g_type_class_add_private (klass, sizeof (GCancellablePrivate));
- if (cancellable_cond == NULL)
- cancellable_cond = g_cond_new ();
-
gobject_class->finalize = g_cancellable_finalize;
/**
g_return_if_fail (G_IS_CANCELLABLE (cancellable));
- G_LOCK(cancellable);
+ g_mutex_lock (&cancellable_mutex);
priv = cancellable->priv;
-
+
while (priv->cancelled_running)
{
priv->cancelled_running_waiting = TRUE;
- g_cond_wait (cancellable_cond, &G_LOCK_NAME (cancellable));
+ g_cond_wait (&cancellable_cond, &cancellable_mutex);
}
if (priv->cancelled)
priv->cancelled = FALSE;
}
- G_UNLOCK(cancellable);
+
+ g_mutex_unlock (&cancellable_mutex);
}
/**
return FALSE;
g_return_val_if_fail (G_IS_CANCELLABLE (cancellable), FALSE);
- G_LOCK(cancellable);
+ g_mutex_lock (&cancellable_mutex);
cancellable->priv->fd_refcount++;
GLIB_PRIVATE_CALL (g_wakeup_get_pollfd) (cancellable->priv->wakeup, pollfd);
- G_UNLOCK(cancellable);
+ g_mutex_unlock (&cancellable_mutex);
return TRUE;
}
priv = cancellable->priv;
- G_LOCK (cancellable);
+ g_mutex_lock (&cancellable_mutex);
+
priv->fd_refcount--;
if (priv->fd_refcount == 0)
{
GLIB_PRIVATE_CALL (g_wakeup_free) (priv->wakeup);
priv->wakeup = NULL;
}
- G_UNLOCK (cancellable);
+
+ g_mutex_unlock (&cancellable_mutex);
}
/**
priv = cancellable->priv;
- G_LOCK(cancellable);
+ g_mutex_lock (&cancellable_mutex);
+
if (priv->cancelled)
{
- G_UNLOCK (cancellable);
+ g_mutex_unlock (&cancellable_mutex);
return;
}
if (priv->wakeup)
GLIB_PRIVATE_CALL (g_wakeup_signal) (priv->wakeup);
- G_UNLOCK(cancellable);
+ g_mutex_unlock (&cancellable_mutex);
g_object_ref (cancellable);
g_signal_emit (cancellable, signals[CANCELLED], 0);
- G_LOCK(cancellable);
+ g_mutex_lock (&cancellable_mutex);
priv->cancelled_running = FALSE;
if (priv->cancelled_running_waiting)
- g_cond_broadcast (cancellable_cond);
+ g_cond_broadcast (&cancellable_cond);
priv->cancelled_running_waiting = FALSE;
- G_UNLOCK(cancellable);
+ g_mutex_unlock (&cancellable_mutex);
g_object_unref (cancellable);
}
g_return_val_if_fail (G_IS_CANCELLABLE (cancellable), 0);
- G_LOCK (cancellable);
+ g_mutex_lock (&cancellable_mutex);
if (cancellable->priv->cancelled)
{
(GClosureNotify) data_destroy_func,
0);
}
- G_UNLOCK (cancellable);
+
+ g_mutex_unlock (&cancellable_mutex);
return id;
}
if (handler_id == 0 || cancellable == NULL)
return;
- G_LOCK (cancellable);
+ g_mutex_lock (&cancellable_mutex);
priv = cancellable->priv;
while (priv->cancelled_running)
{
priv->cancelled_running_waiting = TRUE;
- g_cond_wait (cancellable_cond, &G_LOCK_NAME (cancellable));
+ g_cond_wait (&cancellable_cond, &cancellable_mutex);
}
g_signal_handler_disconnect (cancellable, handler_id);
- G_UNLOCK (cancellable);
+
+ g_mutex_unlock (&cancellable_mutex);
}
typedef struct {