ZifLock

ZifLock — Lock the package system

Synopsis

#define             ZIF_LOCK_ERROR
                    ZifLock;
                    ZifLockClass;
enum                ZifLockError;
enum                ZifLockType;
GQuark              zif_lock_error_quark                (void);
gboolean            zif_lock_is_instance_valid          (void);
gboolean            zif_lock_is_locked                  (ZifLock *lock,
                                                         guint *pid);
ZifLock *           zif_lock_new                        (void);
gboolean            zif_lock_release                    (ZifLock *lock,
                                                         ZifLockType type,
                                                         GError **error);
gboolean            zif_lock_set_locked                 (ZifLock *lock,
                                                         guint *pid,
                                                         GError **error);
gboolean            zif_lock_set_unlocked               (ZifLock *lock,
                                                         GError **error);
gboolean            zif_lock_take                       (ZifLock *lock,
                                                         ZifLockType type,
                                                         GError **error);
const gchar *       zif_lock_type_to_string             (ZifLockType lock_type);

Object Hierarchy

  GObject
   +----ZifLock

Description

This object works with the generic lock file.

Details

ZIF_LOCK_ERROR

#define ZIF_LOCK_ERROR		(zif_lock_error_quark ())


ZifLock

typedef struct _ZifLock ZifLock;


ZifLockClass

typedef struct {
	GObjectClass parent_class;
} ZifLockClass;


enum ZifLockError

typedef enum {
	ZIF_LOCK_ERROR_FAILED,
	ZIF_LOCK_ERROR_ALREADY_LOCKED,
	ZIF_LOCK_ERROR_NOT_LOCKED,
	ZIF_LOCK_ERROR_PERMISSION,
	ZIF_LOCK_ERROR_LAST
} ZifLockError;


enum ZifLockType

typedef enum {
	ZIF_LOCK_TYPE_RPMDB_WRITE,
	ZIF_LOCK_TYPE_REPO_WRITE,
	ZIF_LOCK_TYPE_METADATA_WRITE,
	ZIF_LOCK_TYPE_LAST
} ZifLockType;


zif_lock_error_quark ()

GQuark              zif_lock_error_quark                (void);

Returns :

An error quark.

Since 0.1.0


zif_lock_is_instance_valid ()

gboolean            zif_lock_is_instance_valid          (void);

Returns :

TRUE if a singleton instance already exists

Since 0.1.6


zif_lock_is_locked ()

gboolean            zif_lock_is_locked                  (ZifLock *lock,
                                                         guint *pid);

Gets the lock state.

This function is DEPRECATED as it's not threadsafe.

lock :

A ZifLock

pid :

The PID of the process holding the lock, or NULL

Returns :

TRUE if we are already locked

Since 0.1.0


zif_lock_new ()

ZifLock *           zif_lock_new                        (void);

Returns :

A new lock instance.

Since 0.1.0


zif_lock_release ()

gboolean            zif_lock_release                    (ZifLock *lock,
                                                         ZifLockType type,
                                                         GError **error);

Tries to release a lock for the packaging system.

lock :

A ZifLock

type :

A ZifLockType, e.g. ZIF_LOCK_TYPE_RPMDB_WRITE

error :

A GError, or NULL

Returns :

TRUE if we locked, else FALSE and the error is set

Since 0.1.6


zif_lock_set_locked ()

gboolean            zif_lock_set_locked                 (ZifLock *lock,
                                                         guint *pid,
                                                         GError **error);

Tries to lock the packaging system.

This function is DEPRECATED. Use zif_lock_take() instead.

lock :

A ZifLock

pid :

A PID of the process holding the lock, or NULL

error :

A GError, or NULL

Returns :

TRUE if we locked, else FALSE and the error is set

Since 0.1.0


zif_lock_set_unlocked ()

gboolean            zif_lock_set_unlocked               (ZifLock *lock,
                                                         GError **error);

Unlocks the packaging system.

This function is DEPRECATED. Use zif_lock_take() instead.

lock :

A ZifLock

error :

A GError, or NULL

Returns :

TRUE for success, FALSE otherwise

Since 0.1.0


zif_lock_take ()

gboolean            zif_lock_take                       (ZifLock *lock,
                                                         ZifLockType type,
                                                         GError **error);

Tries to take a lock for the packaging system.

lock :

A ZifLock

type :

A ZifLockType, e.g. ZIF_LOCK_TYPE_RPMDB_WRITE

error :

A GError, or NULL

Returns :

TRUE if we locked, else FALSE and the error is set

Since 0.1.6


zif_lock_type_to_string ()

const gchar *       zif_lock_type_to_string             (ZifLockType lock_type);

lock_type :

Returns :

The string representation of the type

Since 0.1.6