[gnome-software/wip/hughsie/libxmlb: 10/13] Remove most of the GsPluginFlags
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/hughsie/libxmlb: 10/13] Remove most of the GsPluginFlags
- Date: Tue, 16 Oct 2018 16:46:34 +0000 (UTC)
commit 90c9659d975fabca9bc34761ca3f1491813e1bbe
Author: Richard Hughes <richard hughsie com>
Date: Mon Oct 15 17:06:40 2018 +0100
Remove most of the GsPluginFlags
With the move to libxmlb it is no longer required to supress callbacks when the
AsStore has changed. This makes the plugin loader somewhat simpler.
lib/gs-plugin-loader.c | 42 ----------
lib/gs-plugin-private.h | 5 --
lib/gs-plugin-types.h | 8 --
lib/gs-plugin.c | 94 ----------------------
.../gs-plugin-fedora-pkgdb-collections.c | 11 ---
5 files changed, 160 deletions(-)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 46493240..50cb56e5 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -287,42 +287,6 @@ gs_plugin_loader_find_plugin (GsPluginLoader *plugin_loader,
return NULL;
}
-static void
-gs_plugin_loader_action_start (GsPluginLoader *plugin_loader,
- GsPlugin *plugin,
- gboolean exclusive)
-{
- GsPluginLoaderPrivate *priv = gs_plugin_loader_get_instance_private (plugin_loader);
- guint i;
-
- /* set plugin as SELF and all plugins as OTHER */
- gs_plugin_action_start (plugin, exclusive);
- for (i = 0; i < priv->plugins->len; i++) {
- GsPlugin *plugin_tmp;
- plugin_tmp = g_ptr_array_index (priv->plugins, i);
- if (!gs_plugin_get_enabled (plugin_tmp))
- continue;
- gs_plugin_set_running_other (plugin_tmp, TRUE);
- }
-}
-
-static void
-gs_plugin_loader_action_stop (GsPluginLoader *plugin_loader, GsPlugin *plugin)
-{
- GsPluginLoaderPrivate *priv = gs_plugin_loader_get_instance_private (plugin_loader);
- guint i;
-
- /* clear plugin as SELF and all plugins as OTHER */
- gs_plugin_action_stop (plugin);
- for (i = 0; i < priv->plugins->len; i++) {
- GsPlugin *plugin_tmp;
- plugin_tmp = g_ptr_array_index (priv->plugins, i);
- if (!gs_plugin_get_enabled (plugin_tmp))
- continue;
- gs_plugin_set_running_other (plugin_tmp, FALSE);
- }
-}
-
static gboolean
gs_plugin_loader_notify_idle_cb (gpointer user_data)
{
@@ -478,9 +442,7 @@ gs_plugin_loader_run_adopt (GsPluginLoader *plugin_loader, GsAppList *list)
continue;
if (gs_app_has_quirk (app, GS_APP_QUIRK_IS_WILDCARD))
continue;
- gs_plugin_loader_action_start (plugin_loader, plugin, FALSE);
adopt_app_func (plugin, app);
- gs_plugin_loader_action_stop (plugin_loader, plugin);
if (gs_app_get_management_plugin (app) != NULL) {
g_debug ("%s adopted %s",
gs_plugin_get_name (plugin),
@@ -542,7 +504,6 @@ gs_plugin_loader_call_vfunc (GsPluginLoaderHelper *helper,
gs_plugin_job_set_plugin (helper->plugin_job, plugin);
/* run the correct vfunc */
- gs_plugin_loader_action_start (helper->plugin_loader, plugin, FALSE);
if (gs_plugin_job_get_interactive (helper->plugin_job))
gs_plugin_interactive_inc (plugin);
switch (action) {
@@ -735,7 +696,6 @@ gs_plugin_loader_call_vfunc (GsPluginLoaderHelper *helper,
g_critical ("no handler for %s", helper->function_name);
break;
}
- gs_plugin_loader_action_stop (helper->plugin_loader, plugin);
if (gs_plugin_job_get_interactive (helper->plugin_job))
gs_plugin_interactive_dec (plugin);
@@ -3006,9 +2966,7 @@ gs_plugin_loader_generic_update (GsPluginLoader *plugin_loader,
g_object_unref);
gs_plugin_job_set_app (helper->plugin_job, app);
- gs_plugin_loader_action_start (plugin_loader, plugin, FALSE);
ret = plugin_app_func (plugin, app, app_cancellable, &error_local);
- gs_plugin_loader_action_stop (plugin_loader, plugin);
g_cancellable_disconnect (cancellable, cancel_handler_id);
if (!ret) {
diff --git a/lib/gs-plugin-private.h b/lib/gs-plugin-private.h
index 24907278..95b97ee4 100644
--- a/lib/gs-plugin-private.h
+++ b/lib/gs-plugin-private.h
@@ -40,9 +40,6 @@ GsPluginAction gs_plugin_action_from_string (const gchar *action);
const gchar *gs_plugin_action_to_function_name (GsPluginAction action);
void gs_plugin_clear_data (GsPlugin *plugin);
-void gs_plugin_action_start (GsPlugin *plugin,
- gboolean exclusive);
-void gs_plugin_action_stop (GsPlugin *plugin);
void gs_plugin_set_scale (GsPlugin *plugin,
guint scale);
guint gs_plugin_get_order (GsPlugin *plugin);
@@ -59,8 +56,6 @@ void gs_plugin_set_language (GsPlugin *plugin,
const gchar *language);
void gs_plugin_set_auth_array (GsPlugin *plugin,
GPtrArray *auth_array);
-void gs_plugin_set_running_other (GsPlugin *plugin,
- gboolean running_other);
GPtrArray *gs_plugin_get_rules (GsPlugin *plugin,
GsPluginRule rule);
gpointer gs_plugin_get_symbol (GsPlugin *plugin,
diff --git a/lib/gs-plugin-types.h b/lib/gs-plugin-types.h
index 4192c01a..f3c67e8e 100644
--- a/lib/gs-plugin-types.h
+++ b/lib/gs-plugin-types.h
@@ -55,19 +55,11 @@ typedef enum {
/**
* GsPluginFlags:
* @GS_PLUGIN_FLAGS_NONE: No flags set
- * @GS_PLUGIN_FLAGS_RUNNING_SELF: The plugin is running
- * @GS_PLUGIN_FLAGS_RUNNING_OTHER: Another plugin is running
- * @GS_PLUGIN_FLAGS_EXCLUSIVE: An exclusive action is running
- * @GS_PLUGIN_FLAGS_RECENT: This plugin recently ran
* @GS_PLUGIN_FLAGS_INTERACTIVE: User initiated the job
*
* The flags for the plugin at this point in time.
**/
#define GS_PLUGIN_FLAGS_NONE (0u)
-#define GS_PLUGIN_FLAGS_RUNNING_SELF (1u << 0)
-#define GS_PLUGIN_FLAGS_RUNNING_OTHER (1u << 1)
-#define GS_PLUGIN_FLAGS_EXCLUSIVE (1u << 2)
-#define GS_PLUGIN_FLAGS_RECENT (1u << 3)
#define GS_PLUGIN_FLAGS_INTERACTIVE (1u << 4)
typedef guint64 GsPluginFlags;
diff --git a/lib/gs-plugin.c b/lib/gs-plugin.c
index 2b5e130a..4af3bc8a 100644
--- a/lib/gs-plugin.c
+++ b/lib/gs-plugin.c
@@ -65,7 +65,6 @@ typedef struct
GHashTable *cache;
GMutex cache_mutex;
GModule *module;
- GRWLock rwlock;
GsPluginData *data; /* for gs-plugin-{name}.c */
GsPluginFlags flags;
SoupSession *soup_session;
@@ -224,7 +223,6 @@ gs_plugin_finalize (GObject *object)
g_free (priv->data);
g_free (priv->locale);
g_free (priv->language);
- g_rw_lock_clear (&priv->rwlock);
if (priv->auth_array != NULL)
g_ptr_array_unref (priv->auth_array);
if (priv->soup_session != NULL)
@@ -300,79 +298,6 @@ gs_plugin_clear_data (GsPlugin *plugin)
g_clear_pointer (&priv->data, g_free);
}
-/**
- * gs_plugin_action_start:
- * @plugin: a #GsPlugin
- * @exclusive: if the plugin action should be performed exclusively
- *
- * Starts a plugin action.
- *
- * Since: 3.22
- **/
-void
-gs_plugin_action_start (GsPlugin *plugin, gboolean exclusive)
-{
- GsPluginPrivate *priv = gs_plugin_get_instance_private (plugin);
-
- /* lock plugin */
- if (exclusive) {
- g_rw_lock_writer_lock (&priv->rwlock);
- gs_plugin_add_flags (plugin, GS_PLUGIN_FLAGS_EXCLUSIVE);
- } else {
- g_rw_lock_reader_lock (&priv->rwlock);
- }
-
- /* set plugin as SELF */
- gs_plugin_add_flags (plugin, GS_PLUGIN_FLAGS_RUNNING_SELF);
-}
-
-static gboolean
-gs_plugin_action_delay_cb (gpointer user_data)
-{
- GsPlugin *plugin = GS_PLUGIN (user_data);
- GsPluginPrivate *priv = gs_plugin_get_instance_private (plugin);
- g_autoptr(GMutexLocker) locker = g_mutex_locker_new (&priv->timer_mutex);
-
- g_debug ("plugin no longer recently active: %s", priv->name);
- gs_plugin_remove_flags (plugin, GS_PLUGIN_FLAGS_RECENT);
- priv->timer_id = 0;
- return FALSE;
-}
-
-/**
- * gs_plugin_action_stop:
- * @plugin: a #GsPlugin
- *
- * Stops an plugin action.
- *
- * Since: 3.22
- **/
-void
-gs_plugin_action_stop (GsPlugin *plugin)
-{
- GsPluginPrivate *priv = gs_plugin_get_instance_private (plugin);
- g_autoptr(GMutexLocker) locker = g_mutex_locker_new (&priv->timer_mutex);
-
- /* clear plugin as SELF */
- gs_plugin_remove_flags (plugin, GS_PLUGIN_FLAGS_RUNNING_SELF);
-
- /* unlock plugin */
- if (priv->flags & GS_PLUGIN_FLAGS_EXCLUSIVE) {
- g_rw_lock_writer_unlock (&priv->rwlock);
- gs_plugin_remove_flags (plugin, GS_PLUGIN_FLAGS_EXCLUSIVE);
- } else {
- g_rw_lock_reader_unlock (&priv->rwlock);
- }
-
- /* unset this flag after 5 seconds */
- gs_plugin_add_flags (plugin, GS_PLUGIN_FLAGS_RECENT);
- if (priv->timer_id > 0)
- g_source_remove (priv->timer_id);
- priv->timer_id = g_timeout_add (5000,
- gs_plugin_action_delay_cb,
- plugin);
-}
-
/**
* gs_plugin_get_symbol: (skip)
* @plugin: a #GsPlugin
@@ -863,24 +788,6 @@ gs_plugin_remove_flags (GsPlugin *plugin, GsPluginFlags flags)
priv->flags &= ~flags;
}
-/**
- * gs_plugin_set_running_other:
- * @plugin: a #GsPlugin
- * @running_other: %TRUE if another plugin is running
- *
- * Inform the plugin that another plugin is running in the loader.
- *
- * Since: 3.22
- **/
-void
-gs_plugin_set_running_other (GsPlugin *plugin, gboolean running_other)
-{
- if (running_other)
- gs_plugin_add_flags (plugin, GS_PLUGIN_FLAGS_RUNNING_OTHER);
- else
- gs_plugin_remove_flags (plugin, GS_PLUGIN_FLAGS_RUNNING_OTHER);
-}
-
/**
* gs_plugin_add_rule:
* @plugin: a #GsPlugin
@@ -2159,7 +2066,6 @@ gs_plugin_init (GsPlugin *plugin)
g_mutex_init (&priv->interactive_mutex);
g_mutex_init (&priv->timer_mutex);
g_mutex_init (&priv->vfuncs_mutex);
- g_rw_lock_init (&priv->rwlock);
}
/**
diff --git a/plugins/fedora-pkgdb-collections/gs-plugin-fedora-pkgdb-collections.c
b/plugins/fedora-pkgdb-collections/gs-plugin-fedora-pkgdb-collections.c
index d3f516c2..c862d542 100644
--- a/plugins/fedora-pkgdb-collections/gs-plugin-fedora-pkgdb-collections.c
+++ b/plugins/fedora-pkgdb-collections/gs-plugin-fedora-pkgdb-collections.c
@@ -109,17 +109,6 @@ _file_changed_cb (GFileMonitor *monitor,
GsPlugin *plugin = GS_PLUGIN (user_data);
GsPluginData *priv = gs_plugin_get_data (plugin);
- /* only reload the update list if the plugin is NOT running itself
- * and the time since it ran is greater than 5 seconds (inotify FTW) */
- if (gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_RUNNING_SELF)) {
- g_debug ("no notify as plugin %s active", gs_plugin_get_name (plugin));
- return;
- }
- if (gs_plugin_has_flags (plugin, GS_PLUGIN_FLAGS_RECENT)) {
- g_debug ("no notify as plugin %s recently active", gs_plugin_get_name (plugin));
- return;
- }
-
g_debug ("cache file changed, so reloading upgrades list");
gs_plugin_updates_changed (plugin);
priv->is_valid = FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]