[gimp/gimp-2-10] app: flush async-operations queue when setting async thread count to 0
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: flush async-operations queue when setting async thread count to 0
- Date: Sun, 15 Jul 2018 09:08:53 +0000 (UTC)
commit bc312531fbd2c4a1dc9294f4cce57dfc8e5a8fe8
Author: Ell <ell_se yahoo com>
Date: Sun Jul 15 04:58:29 2018 -0400
app: flush async-operations queue when setting async thread count to 0
In gimp-parallel, always flush the async-operations queue (by
executing all remaining operations on the caller thread) when
setting the async-pool thread count to 0 (as happens when setting
GEGL_THREADS=1, per the previous commit,) and not only when
shutting GIMP down. Otherwise, pending asynchronous operations
can "get lost" when setting GEGL_THREADS to 1.
Additionally, in gimp_gegl_init(), initialize gimp-parallel before
before connecting to GimpGeglConfig's "notify::num-processors"
signal, so that the number of async threads is set *before*
GEGL_THREADS, in order to avoid setting GEGL_THREADS to 1 while
async operations are still executing.
Also, allow setting the number of gimp-parallel-distribute threads
while a gimp-parallel-distribute function is running (which can
happen if gimp-parallel-distribute is used in an async operation,
as is the case for histogram calculation), by waiting for the
parallel-distribute function to finish before setting the number of
threads.
(cherry picked from commit 432a8847159c33c2aca89a18b519fb5aab4c398f)
app/core/gimp-parallel.cc | 34 +++++++++++++++++-----------------
app/gegl/gimp-gegl.c | 4 ++--
2 files changed, 19 insertions(+), 19 deletions(-)
---
diff --git a/app/core/gimp-parallel.cc b/app/core/gimp-parallel.cc
index 5846dadb05..46bdfd5600 100644
--- a/app/core/gimp-parallel.cc
+++ b/app/core/gimp-parallel.cc
@@ -140,8 +140,6 @@ gimp_parallel_init (Gimp *gimp)
void
gimp_parallel_exit (Gimp *gimp)
{
- GimpParallelRunAsyncTask *task;
-
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_signal_handlers_disconnect_by_func (gimp->config,
@@ -150,16 +148,6 @@ gimp_parallel_exit (Gimp *gimp)
/* stop all threads */
gimp_parallel_set_n_threads (0);
-
- /* finish remaining tasks */
- while ((task = (GimpParallelRunAsyncTask *)
- g_queue_pop_head (&gimp_parallel_run_async_queue)))
- {
- g_object_set_data (G_OBJECT (task->async),
- "gimp-parallel-run-async-link", NULL);
-
- gimp_parallel_run_async_execute_task (task);
- }
}
GimpAsync *
@@ -521,6 +509,21 @@ gimp_parallel_run_async_set_n_threads (gint n_threads)
}
gimp_parallel_run_async_n_threads = n_threads;
+
+ if (n_threads == 0)
+ {
+ GimpParallelRunAsyncTask *task;
+
+ /* finish remaining tasks */
+ while ((task = (GimpParallelRunAsyncTask *)
+ g_queue_pop_head (&gimp_parallel_run_async_queue)))
+ {
+ g_object_set_data (G_OBJECT (task->async),
+ "gimp-parallel-run-async-link", NULL);
+
+ gimp_parallel_run_async_execute_task (task);
+ }
+ }
}
static gpointer
@@ -613,11 +616,8 @@ gimp_parallel_distribute_set_n_threads (gint n_threads)
{
gint i;
- if (! g_atomic_int_compare_and_exchange (&gimp_parallel_distribute_busy,
- 0, 1))
- {
- g_return_if_reached ();
- }
+ while (! g_atomic_int_compare_and_exchange (&gimp_parallel_distribute_busy,
+ 0, 1));
n_threads = CLAMP (n_threads, 1, GIMP_PARALLEL_DISTRIBUTE_MAX_THREADS);
diff --git a/app/gegl/gimp-gegl.c b/app/gegl/gimp-gegl.c
index 1a67d42c9f..af0c28efca 100644
--- a/app/gegl/gimp-gegl.c
+++ b/app/gegl/gimp-gegl.c
@@ -57,6 +57,8 @@ gimp_gegl_init (Gimp *gimp)
"use-opencl", config->use_opencl,
NULL);
+ gimp_parallel_init (gimp);
+
g_signal_connect (config, "notify::tile-cache-size",
G_CALLBACK (gimp_gegl_notify_tile_cache_size),
NULL);
@@ -67,8 +69,6 @@ gimp_gegl_init (Gimp *gimp)
G_CALLBACK (gimp_gegl_notify_use_opencl),
NULL);
- gimp_parallel_init (gimp);
-
gimp_babl_init ();
gimp_operations_init (gimp);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]