[gnome-software/mwleeds/hardcoded-pwa-list: 9/10] epiphany: Set job prio based on interactivity




commit 0978bc19749f5cad24d1afc585ced81a2c314120
Author: Phaedrus Leeds <mwleeds protonmail com>
Date:   Mon May 16 14:15:44 2022 -0700

    epiphany: Set job prio based on interactivity

 plugins/epiphany/gs-plugin-epiphany.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/plugins/epiphany/gs-plugin-epiphany.c b/plugins/epiphany/gs-plugin-epiphany.c
index 8d98833f7..4fb82beef 100644
--- a/plugins/epiphany/gs-plugin-epiphany.c
+++ b/plugins/epiphany/gs-plugin-epiphany.c
@@ -404,6 +404,12 @@ gs_plugin_adopt_app (GsPlugin *plugin,
        }
 }
 
+static gint
+get_priority_for_interactivity (gboolean interactive)
+{
+       return interactive ? G_PRIORITY_DEFAULT : G_PRIORITY_LOW;
+}
+
 static void list_installed_apps_thread_cb (GTask        *task,
                                            gpointer      source_object,
                                            gpointer      task_data,
@@ -418,12 +424,13 @@ gs_plugin_epiphany_list_installed_apps_async (GsPlugin                       *pl
 {
        GsPluginEpiphany *self = GS_PLUGIN_EPIPHANY (plugin);
        g_autoptr(GTask) task = NULL;
+       gboolean interactive = (flags & GS_PLUGIN_LIST_INSTALLED_APPS_FLAGS_INTERACTIVE);
 
        task = g_task_new (plugin, cancellable, callback, user_data);
        g_task_set_source_tag (task, gs_plugin_epiphany_list_installed_apps_async);
 
        /* Queue a job to get the installed apps. */
-       gs_worker_thread_queue (self->worker, G_PRIORITY_DEFAULT,
+       gs_worker_thread_queue (self->worker, get_priority_for_interactivity (interactive),
                                list_installed_apps_thread_cb, g_steal_pointer (&task));
 }
 
@@ -792,12 +799,13 @@ gs_plugin_epiphany_refine_async (GsPlugin            *plugin,
 {
        GsPluginEpiphany *self = GS_PLUGIN_EPIPHANY (plugin);
        g_autoptr(GTask) task = NULL;
+       gboolean interactive = gs_plugin_has_flags (GS_PLUGIN (self), GS_PLUGIN_FLAGS_INTERACTIVE);
 
        task = gs_plugin_refine_data_new_task (plugin, list, flags, cancellable, callback, user_data);
        g_task_set_source_tag (task, gs_plugin_epiphany_refine_async);
 
        /* Queue a job for the refine. */
-       gs_worker_thread_queue (self->worker, G_PRIORITY_DEFAULT,
+       gs_worker_thread_queue (self->worker, get_priority_for_interactivity (interactive),
                                refine_thread_cb, g_steal_pointer (&task));
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]