Commit 62baffed authored by Ell's avatar Ell

app: in gimp-parallel, boost priority of waited-upon asyncs

When an async that was created through
gimp_parallel_run_async[_full](), and whose execution is still
pending, is being waited-upon, maximize its priority so that it
gets executed before all other pending asyncs.

Note that we deliberately don't simply execute the async in the
calling thread in this case, to allow timed-waits to fail (which is
especially important for gimp_wait()).
parent 965da12b
......@@ -83,6 +83,7 @@ static GimpParallelRunAsyncTask * gimp_parallel_run_async_dequeue_task (void);
static gboolean gimp_parallel_run_async_execute_task (GimpParallelRunAsyncTask *task);
static void gimp_parallel_run_async_abort_task (GimpParallelRunAsyncTask *task);
static void gimp_parallel_run_async_cancel (GimpAsync *async);
static void gimp_parallel_run_async_waiting (GimpAsync *async);
/* local variables */
......@@ -160,6 +161,9 @@ gimp_parallel_run_async_full (gint priority,
g_signal_connect_after (async, "cancel",
G_CALLBACK (gimp_parallel_run_async_cancel),
g_signal_connect_after (async, "waiting",
G_CALLBACK (gimp_parallel_run_async_waiting),
g_mutex_lock (&gimp_parallel_run_async_mutex);
......@@ -498,4 +502,33 @@ gimp_parallel_run_async_cancel (GimpAsync *async)
gimp_parallel_run_async_abort_task (task);
static void
gimp_parallel_run_async_waiting (GimpAsync *async)
GList *link;
link = (GList *) g_object_get_data (G_OBJECT (async),
if (! link)
g_mutex_lock (&gimp_parallel_run_async_mutex);
link = (GList *) g_object_get_data (G_OBJECT (async),
if (link)
GimpParallelRunAsyncTask *task = (GimpParallelRunAsyncTask *) link->data;
task->priority = G_MININT;
g_queue_unlink (&gimp_parallel_run_async_queue, link);
g_queue_push_head_link (&gimp_parallel_run_async_queue, link);
g_mutex_unlock (&gimp_parallel_run_async_mutex);
} /* extern "C" */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment