summaryrefslogtreecommitdiff
path: root/libview
diff options
context:
space:
mode:
Diffstat (limited to 'libview')
-rw-r--r--libview/ev-job-scheduler.c13
-rw-r--r--libview/ev-job-scheduler.h9
2 files changed, 17 insertions, 5 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);
+}
diff --git a/libview/ev-job-scheduler.h b/libview/ev-job-scheduler.h
index 68e9f59b..fae80a85 100644
--- a/libview/ev-job-scheduler.h
+++ b/libview/ev-job-scheduler.h
@@ -38,10 +38,11 @@ typedef enum {
EV_JOB_N_PRIORITIES
} EvJobPriority;
-void ev_job_scheduler_push_job (EvJob *job,
- EvJobPriority priority);
-void ev_job_scheduler_update_job (EvJob *job,
- EvJobPriority priority);
+void ev_job_scheduler_push_job (EvJob *job,
+ EvJobPriority priority);
+void ev_job_scheduler_update_job (EvJob *job,
+ EvJobPriority priority);
+EvJob *ev_job_scheduler_get_running_thread_job (void);
G_END_DECLS