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.
G_LOCK_DEFINE_STATIC(job_list);
static GSList *job_list = NULL;
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);
static gpointer ev_job_thread_proxy (gpointer data);
static void ev_scheduler_thread_job_cancelled (EvSchedulerJob *job,
GCancellable *cancellable);
do {
if (g_cancellable_is_cancelled (job->cancellable))
result = FALSE;
do {
if (g_cancellable_is_cancelled (job->cancellable))
result = FALSE;
+ else {
+ g_atomic_pointer_set (&running_job, job);
result = ev_job_run (job);
result = ev_job_run (job);
+
+ g_atomic_pointer_set (&running_job, NULL);
+EvJob *
+ev_job_scheduler_get_running_thread_job (void)
+{
+ return g_atomic_pointer_get (&running_job);
+}
EV_JOB_N_PRIORITIES
} EvJobPriority;
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);