[gnome-software: 1/8] gs-plugin-loader: Factor out gs_plugin_loader_hint_job_finished()




commit 1d15c6c3288cb885d757493a13eada46aa6440c0
Author: Philip Withnall <pwithnall endlessos org>
Date:   Tue Feb 22 15:08:48 2022 +0000

    gs-plugin-loader: Factor out gs_plugin_loader_hint_job_finished()
    
    Some plugin jobs might cause several signal emissions of changes as they
    progress. The plugin loader currently queues those up and emits them
    when a job is finished.
    
    If jobs are being moved out to external `GsPluginJob` objects, those
    objects need a way to signal to the `GsPluginLoader` that they are done
    potentially emitting signals.
    
    Refactor the existing code to do that, and expose it in a
    `GsPluginLoader` API.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>
    
    Helps: #1472

 lib/gs-plugin-loader.c | 32 ++++++++++++++++++++++++++------
 lib/gs-plugin-loader.h |  2 ++
 2 files changed, 28 insertions(+), 6 deletions(-)
---
diff --git a/lib/gs-plugin-loader.c b/lib/gs-plugin-loader.c
index 6c65e41fa..5b17e2677 100644
--- a/lib/gs-plugin-loader.c
+++ b/lib/gs-plugin-loader.c
@@ -3407,9 +3407,8 @@ gs_plugin_loader_process_thread_cb (GTask *task,
        /* sort these again as the refine may have added useful metadata */
        gs_plugin_loader_job_sorted_truncation_again (helper);
 
-       /* if the plugin used updates-changed actually schedule it now */
-       if (plugin_loader->updates_changed_cnt > 0)
-               gs_plugin_loader_updates_changed (plugin_loader);
+       /* Hint that the job has finished. */
+       gs_plugin_loader_hint_job_finished (plugin_loader);
 
 #ifdef HAVE_SYSPROF
        if (plugin_loader->sysprof_writer != NULL) {
@@ -3576,9 +3575,8 @@ run_job_cb (GObject      *source_object,
        }
 #endif  /* HAVE_SYSPROF */
 
-       /* if the plugin used updates-changed actually schedule it now */
-       if (plugin_loader->updates_changed_cnt > 0)
-               gs_plugin_loader_updates_changed (plugin_loader);
+       /* Hint that the job has finished. */
+       gs_plugin_loader_hint_job_finished (plugin_loader);
 
        /* FIXME: This will eventually go away when
         * gs_plugin_loader_job_process_finish() is removed. */
@@ -4136,3 +4134,25 @@ gs_plugin_loader_get_category_manager (GsPluginLoader *plugin_loader)
 
        return plugin_loader->category_manager;
 }
+
+/**
+ * gs_plugin_loader_hint_job_finished:
+ * @plugin_loader: a #GsPluginLoader
+ *
+ * Hint to the @plugin_loader that the set of changes caused by the current
+ * #GsPluginJob is likely to be finished.
+ *
+ * The @plugin_loader may emit queued-up signals as a result.
+ *
+ * Since: 42
+ */
+void
+gs_plugin_loader_hint_job_finished (GsPluginLoader *plugin_loader)
+{
+       g_return_if_fail (GS_IS_PLUGIN_LOADER (plugin_loader));
+
+       /* if the plugin used updates-changed during its job, actually schedule
+        * the signal emission now */
+       if (plugin_loader->updates_changed_cnt > 0)
+               gs_plugin_loader_updates_changed (plugin_loader);
+}
diff --git a/lib/gs-plugin-loader.h b/lib/gs-plugin-loader.h
index a7dd40104..758389560 100644
--- a/lib/gs-plugin-loader.h
+++ b/lib/gs-plugin-loader.h
@@ -116,4 +116,6 @@ gboolean     gs_plugin_loader_app_is_valid          (GsApp *app,
 void            gs_plugin_loader_run_adopt             (GsPluginLoader *plugin_loader,
                                                         GsAppList *list);
 
+void            gs_plugin_loader_hint_job_finished     (GsPluginLoader *plugin_loader);
+
 G_END_DECLS


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