[gnome-software: 4/9] appstream: Set worker thread job priorities based on job interactivity




commit 965db0ec0512b2511bfb0380853ec69b3737d220
Author: Philip Withnall <pwithnall endlessos org>
Date:   Mon Mar 28 15:30:16 2022 +0100

    appstream: Set worker thread job priorities based on job interactivity
    
    See the preceding commits for details.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>

 plugins/core/gs-plugin-appstream.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/plugins/core/gs-plugin-appstream.c b/plugins/core/gs-plugin-appstream.c
index 77f3cbc7e..cec8160e3 100644
--- a/plugins/core/gs-plugin-appstream.c
+++ b/plugins/core/gs-plugin-appstream.c
@@ -861,6 +861,12 @@ gs_plugin_appstream_check_silo (GsPluginAppstream  *self,
        return TRUE;
 }
 
+static gint
+get_priority_for_interactivity (gboolean interactive)
+{
+       return interactive ? G_PRIORITY_DEFAULT : G_PRIORITY_LOW;
+}
+
 static void setup_thread_cb (GTask        *task,
                              gpointer      source_object,
                              gpointer      task_data,
@@ -1175,12 +1181,13 @@ gs_plugin_appstream_refine_async (GsPlugin            *plugin,
 {
        GsPluginAppstream *self = GS_PLUGIN_APPSTREAM (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_appstream_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));
 }
 
@@ -1384,12 +1391,13 @@ gs_plugin_appstream_list_installed_apps_async (GsPlugin                       *p
 {
        GsPluginAppstream *self = GS_PLUGIN_APPSTREAM (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_appstream_list_installed_apps_async);
 
        /* Queue a job to check the silo, which will cause it to be loaded. */
-       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));
 }
 
@@ -1550,12 +1558,13 @@ gs_plugin_appstream_refresh_metadata_async (GsPlugin                     *plugin
 {
        GsPluginAppstream *self = GS_PLUGIN_APPSTREAM (plugin);
        g_autoptr(GTask) task = NULL;
+       gboolean interactive = (flags & GS_PLUGIN_REFRESH_METADATA_FLAGS_INTERACTIVE);
 
        task = g_task_new (plugin, cancellable, callback, user_data);
        g_task_set_source_tag (task, gs_plugin_appstream_refresh_metadata_async);
 
        /* Queue a job to check the silo, which will cause it to be refreshed if needed. */
-       gs_worker_thread_queue (self->worker, G_PRIORITY_DEFAULT,
+       gs_worker_thread_queue (self->worker, get_priority_for_interactivity (interactive),
                                refresh_metadata_thread_cb, g_steal_pointer (&task));
 }
 


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