/** * hif_state_take_lock: **/ gboolean hif_state_take_lock (HifState *state, HifLockType lock_type, HifLockMode lock_mode, GError **error) { gboolean ret = TRUE; guint lock_id = 0; /* no custom handler */ lock_id = hif_lock_take (state->priv->lock, lock_type, lock_mode, error); if (lock_id == 0) { ret = FALSE; goto out; } /* add the lock to an array so we can release on completion */ g_debug ("adding lock %i", lock_id); g_ptr_array_add (state->priv->lock_ids, GUINT_TO_POINTER (lock_id)); out: return ret; }
/** * hif_state_take_lock: * @state: A #HifState * @lock_type: A #HifLockType, e.g. %HIF_LOCK_TYPE_RPMDB * @lock_mode: A #HifLockMode, e.g. %HIF_LOCK_MODE_PROCESS * @error: A #GError * * Takes a lock of a specified type. * The lock is automatically free'd when the HifState has been completed. * * You can call hif_state_take_lock() multiple times with different or * even the same @lock_type value. * * Returns: %FALSE if the lock is fatal, %TRUE otherwise * * Since: 0.1.0 **/ gboolean hif_state_take_lock(HifState *state, HifLockType lock_type, HifLockMode lock_mode, GError **error) { HifStatePrivate *priv = GET_PRIVATE(state); guint lock_id = 0; /* no custom handler */ lock_id = hif_lock_take(priv->lock, lock_type, lock_mode, error); if (lock_id == 0) return FALSE; /* add the lock to an array so we can release on completion */ g_debug("adding lock %i", lock_id); g_ptr_array_add(priv->lock_ids, GUINT_TO_POINTER(lock_id)); return TRUE; }