[gnome-software: 16/72] repos: Make refine asynchronous
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 16/72] repos: Make refine asynchronous
- Date: Wed, 15 Dec 2021 13:00:54 +0000 (UTC)
commit 20930f38df29def5a2aaa242d32f43e0cbce5ef1
Author: Philip Withnall <pwithnall endlessos org>
Date: Fri Oct 22 16:09:15 2021 +0100
repos: Make refine asynchronous
Signed-off-by: Philip Withnall <pwithnall endlessos org>
Helps: #1472
plugins/repos/gs-plugin-repos.c | 35 ++++++++++++++++++++++++++---------
1 file changed, 26 insertions(+), 9 deletions(-)
---
diff --git a/plugins/repos/gs-plugin-repos.c b/plugins/repos/gs-plugin-repos.c
index 57cc75e75..2188b026e 100644
--- a/plugins/repos/gs-plugin-repos.c
+++ b/plugins/repos/gs-plugin-repos.c
@@ -354,21 +354,28 @@ refine_app (GsApp *app,
}
}
-gboolean
-gs_plugin_refine (GsPlugin *plugin,
- GsAppList *list,
- GsPluginRefineFlags flags,
- GCancellable *cancellable,
- GError **error)
+static void
+gs_plugin_repos_refine_async (GsPlugin *plugin,
+ GsAppList *list,
+ GsPluginRefineFlags flags,
+ GCancellable *cancellable,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
{
GsPluginRepos *self = GS_PLUGIN_REPOS (plugin);
g_autoptr(GHashTable) filenames = NULL; /* (element-type utf8 filename) mapping origin to filename */
g_autoptr(GHashTable) urls = NULL; /* (element-type utf8 utf8) mapping origin to URL */
g_autoptr(GMutexLocker) locker = NULL;
+ g_autoptr(GTask) task = NULL;
+
+ task = g_task_new (plugin, cancellable, callback, user_data);
+ g_task_set_source_tag (task, gs_plugin_repos_refine_async);
/* nothing to do here */
- if ((flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN_HOSTNAME) == 0)
- return TRUE;
+ if ((flags & GS_PLUGIN_REFINE_FLAGS_REQUIRE_ORIGIN_HOSTNAME) == 0) {
+ g_task_return_boolean (task, TRUE);
+ return;
+ }
/* Grab a reference to the object’s state so it can be accessed without
* holding the lock throughout, to keep the critical section small. */
@@ -384,7 +391,15 @@ gs_plugin_refine (GsPlugin *plugin,
refine_app (app, flags, filenames, urls);
}
- return TRUE;
+ g_task_return_boolean (task, TRUE);
+}
+
+static gboolean
+gs_plugin_repos_refine_finish (GsPlugin *plugin,
+ GAsyncResult *result,
+ GError **error)
+{
+ return g_task_propagate_boolean (G_TASK (result), error);
}
static void
@@ -400,6 +415,8 @@ gs_plugin_repos_class_init (GsPluginReposClass *klass)
plugin_class->setup_finish = gs_plugin_repos_setup_finish;
plugin_class->shutdown_async = gs_plugin_repos_shutdown_async;
plugin_class->shutdown_finish = gs_plugin_repos_shutdown_finish;
+ plugin_class->refine_async = gs_plugin_repos_refine_async;
+ plugin_class->refine_finish = gs_plugin_repos_refine_finish;
}
GType
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]