diff options
author | infirit <[email protected]> | 2014-12-09 15:47:04 +0100 |
---|---|---|
committer | infirit <[email protected]> | 2014-12-09 23:02:28 +0100 |
commit | 5abb88d4376fdb478455a6acb9a8d322d51da5ee (patch) | |
tree | c79db8ef015be0ae4059271bc5a3f9a3bf1c45a4 /libview/ev-job-scheduler.c | |
parent | e9f1cf80bff9c730ccb6d76008ae6c5d0d0c8bcf (diff) | |
download | atril-5abb88d4376fdb478455a6acb9a8d322d51da5ee.tar.bz2 atril-5abb88d4376fdb478455a6acb9a8d322d51da5ee.tar.xz |
libview: add a method to get the job currently running in the worker thread
When a job is cancelled while it's running, the cancelled signal might be
emitted before the job finishes, and since the finished signal is not
emitted for cancelled jobs, it's not possible to know when the job has
finished. With this method we can see whether the job is still running
and wait until it finishes.
Taken from evince commit: 23e76eac47c60ab885edcdb6a337ee7587afa7e8
From: Carlos Garcia Campos <[email protected]>
Diffstat (limited to 'libview/ev-job-scheduler.c')
-rw-r--r-- | libview/ev-job-scheduler.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/libview/ev-job-scheduler.c b/libview/ev-job-scheduler.c index 4cb6864c..dfb32496 100644 --- a/libview/ev-job-scheduler.c +++ b/libview/ev-job-scheduler.c @@ -30,6 +30,8 @@ typedef struct _EvSchedulerJob { G_LOCK_DEFINE_STATIC(job_list); static GSList *job_list = NULL; +static volatile EvJob *running_job = NULL; + static gpointer ev_job_thread_proxy (gpointer data); static void ev_scheduler_thread_job_cancelled (EvSchedulerJob *job, GCancellable *cancellable); @@ -177,9 +179,13 @@ ev_job_thread (EvJob *job) do { if (g_cancellable_is_cancelled (job->cancellable)) result = FALSE; - else + else { + g_atomic_pointer_set (&running_job, job); result = ev_job_run (job); + } } while (result); + + g_atomic_pointer_set (&running_job, NULL); } static gboolean @@ -301,3 +307,8 @@ ev_job_scheduler_update_job (EvJob *job, } } +EvJob * +ev_job_scheduler_get_running_thread_job (void) +{ + return g_atomic_pointer_get (&running_job); +} |