[gnome-software: 7/9] flatpak: Set worker thread job priorities based on job interactivity
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 7/9] flatpak: Set worker thread job priorities based on job interactivity
- Date: Tue, 29 Mar 2022 06:22:31 +0000 (UTC)
commit 699bb1b6c5a382fe873ee3d1fa758d1a158b6953
Author: Philip Withnall <pwithnall endlessos org>
Date: Mon Mar 28 15:31:30 2022 +0100
flatpak: Set worker thread job priorities based on job interactivity
See the preceding commits for details.
Signed-off-by: Philip Withnall <pwithnall endlessos org>
plugins/flatpak/gs-plugin-flatpak.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/plugins/flatpak/gs-plugin-flatpak.c b/plugins/flatpak/gs-plugin-flatpak.c
index 15e60404d..78b08b9c6 100644
--- a/plugins/flatpak/gs-plugin-flatpak.c
+++ b/plugins/flatpak/gs-plugin-flatpak.c
@@ -156,6 +156,12 @@ gs_plugin_flatpak_report_warning (GsPlugin *plugin,
gs_plugin_report_event (plugin, event);
}
+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,
@@ -365,13 +371,14 @@ gs_plugin_flatpak_list_installed_apps_async (GsPlugin *plu
{
GsPluginFlatpak *self = GS_PLUGIN_FLATPAK (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_flatpak_list_installed_apps_async);
g_task_set_task_data (task, GINT_TO_POINTER (flags), NULL);
/* 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));
}
@@ -460,13 +467,14 @@ gs_plugin_flatpak_refresh_metadata_async (GsPlugin *plugin,
{
GsPluginFlatpak *self = GS_PLUGIN_FLATPAK (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_flatpak_refresh_metadata_async);
g_task_set_task_data (task, gs_plugin_refresh_metadata_data_new (cache_age_secs, flags),
(GDestroyNotify) gs_plugin_refresh_metadata_data_free);
/* 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),
refresh_metadata_thread_cb, g_steal_pointer (&task));
}
@@ -619,12 +627,13 @@ gs_plugin_flatpak_refine_async (GsPlugin *plugin,
{
GsPluginFlatpak *self = GS_PLUGIN_FLATPAK (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_flatpak_refine_async);
/* Queue a job to refine the apps. */
- 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]