static GQueue *thumbnail_queue_high = NULL;
static GQueue *thumbnail_queue_low = NULL;
static GQueue *load_queue = NULL;
-static GQueue *xfer_queue = NULL;
+static GQueue *save_queue = NULL;
+static GQueue *fonts_queue = NULL;
+static GQueue *print_queue = NULL;
/* Queues used for backends supporting EvAsyncRender interface,
they are executed on the main thread */
g_queue_push_tail (queue, job);
}
+/**
+ * add_job_to_queue_locked:
+ * @queue: a #GQueue where the #EvJob will be added.
+ * @job: an #EvJob to be added to the specified #GQueue.
+ *
+ * Add the #EvJob to the specified #GQueue and woke up the ev_render_thread who
+ * is waiting for render_cond.
+ */
static void
add_job_to_queue_locked (GQueue *queue,
EvJob *job)
g_cond_broadcast (render_cond);
}
+/**
+ * notify_finished:
+ * @job: the object that signal will be reseted.
+ *
+ * It does emit the job finished signal and returns %FALSE.
+ *
+ * Returns: %FALSE.
+ */
static gboolean
notify_finished (GObject *job)
{
return FALSE;
}
+/**
+ * job_finished_cb:
+ * @job: the #EvJob that has been handled.
+ *
+ * It does finish the job last work and look if there is any more job to be
+ * handled.
+ */
static void
job_finished_cb (EvJob *job)
{
ev_job_queue_run_next ();
}
+/**
+ * handle_job:
+ * @job: the #EvJob to be handled.
+ *
+ * First, it does check if the job is async and then it does attend it if
+ * possible giving a failed assertion otherwise. If the job isn't async it does
+ * attend it and notify that the job has been finished.
+ */
static void
handle_job (EvJob *job)
{
ev_job_links_run (EV_JOB_LINKS (job));
else if (EV_IS_JOB_LOAD (job))
ev_job_load_run (EV_JOB_LOAD (job));
- else if (EV_IS_JOB_XFER (job))
- ev_job_xfer_run (EV_JOB_XFER (job));
+ else if (EV_IS_JOB_SAVE (job))
+ ev_job_save_run (EV_JOB_SAVE (job));
else if (EV_IS_JOB_RENDER (job))
ev_job_render_run (EV_JOB_RENDER (job));
+ else if (EV_IS_JOB_FONTS (job))
+ ev_job_fonts_run (EV_JOB_FONTS (job));
+ else if (EV_IS_JOB_PRINT (job))
+ ev_job_print_run (EV_JOB_PRINT (job));
if (!EV_JOB (job)->async) {
/* We let the idle own a ref, as we (the queue) are done with the job. */
}
}
+/**
+ * search_for_jobs_unlocked:
+ *
+ * Check if there is any job at the synchronized queues and return any existing
+ * job in them taking in account the next priority:
+ *
+ * render_queue_high >
+ * thumbnail_queue_high >
+ * render_queue_low >
+ * links_queue >
+ * load_queue >
+ * thumbnail_queue_low >
+ * fonts_queue >
+ * print_queue >
+ *
+ * Returns: an available #EvJob in the queues taking in account stablished queue
+ * priorities.
+ */
static EvJob *
search_for_jobs_unlocked (void)
{
if (job)
return job;
- job = (EvJob *) g_queue_pop_head (xfer_queue);
+ job = (EvJob *) g_queue_pop_head (save_queue);
if (job)
return job;
if (job)
return job;
+ job = (EvJob *) g_queue_pop_head (fonts_queue);
+ if (job)
+ return job;
+
+ job = (EvJob *) g_queue_pop_head (print_queue);
+ if (job)
+ return job;
+
return NULL;
}
+/**
+ * no_jobs_available_unlocked:
+ *
+ * Looks if there is any job at render, links, load, thumbnail. fonts and print
+ * queues.
+ *
+ * Returns: %TRUE if the render, links, load, thumbnail, fonts and print queues
+ * are empty, %FALSE in other case.
+ */
static gboolean
no_jobs_available_unlocked (void)
{
&& g_queue_is_empty (render_queue_low)
&& g_queue_is_empty (links_queue)
&& g_queue_is_empty (load_queue)
- && g_queue_is_empty (xfer_queue)
+ && g_queue_is_empty (save_queue)
&& g_queue_is_empty (thumbnail_queue_high)
- && g_queue_is_empty (thumbnail_queue_low);
+ && g_queue_is_empty (thumbnail_queue_low)
+ && g_queue_is_empty (fonts_queue)
+ && g_queue_is_empty (print_queue);
}
/* the thread mainloop function */
+/**
+ * ev_render_thread:
+ * @data: data passed to the thread.
+ *
+ * The thread mainloop function. It does wait for any available job in synced
+ * queues to handle it.
+ *
+ * Returns: the return value of the thread, which will be returned by
+ * g_thread_join().
+ */
static gpointer
ev_render_thread (gpointer data)
{
}
+/**
+ * ev_job_queue_run_next:
+ *
+ * It does look for any job on the render high priority queue first and after
+ * in the render low priority one, and then it does handle it.
+ */
static void
ev_job_queue_run_next (void)
{
}
/* Public Functions */
+/**
+ * ev_job_queue_init:
+ *
+ * Creates a new cond, new mutex, a thread for evince job handling and inits
+ * every queue.
+ */
void
ev_job_queue_init (void)
{
links_queue = g_queue_new ();
load_queue = g_queue_new ();
- xfer_queue = g_queue_new ();
+ save_queue = g_queue_new ();
render_queue_high = g_queue_new ();
render_queue_low = g_queue_new ();
async_render_queue_high = g_queue_new ();
async_render_queue_low = g_queue_new ();
thumbnail_queue_high = g_queue_new ();
thumbnail_queue_low = g_queue_new ();
+ fonts_queue = g_queue_new ();
+ print_queue = g_queue_new ();
g_thread_create (ev_render_thread, NULL, FALSE, NULL);
} else if (EV_IS_JOB_LOAD (job)) {
/* the priority doesn't effect load */
return load_queue;
- } else if (EV_IS_JOB_XFER (job)) {
- /* the priority doesn't effect xfer */
- return xfer_queue;
+ } else if (EV_IS_JOB_SAVE (job)) {
+ /* the priority doesn't effect save */
+ return save_queue;
} else if (EV_IS_JOB_LINKS (job)) {
/* the priority doesn't effect links */
return links_queue;
+ } else if (EV_IS_JOB_FONTS (job)) {
+ /* the priority doesn't effect fonts */
+ return fonts_queue;
+ } else if (EV_IS_JOB_PRINT (job)) {
+ /* the priority doesn't effect print */
+ return print_queue;
}
}
retval = remove_job_from_queue_locked (links_queue, job);
} else if (EV_IS_JOB_LOAD (job)) {
retval = remove_job_from_queue_locked (load_queue, job);
- } else if (EV_IS_JOB_XFER (job)) {
- retval = remove_job_from_queue_locked (xfer_queue, job);
+ } else if (EV_IS_JOB_SAVE (job)) {
+ retval = remove_job_from_queue_locked (save_queue, job);
+ } else if (EV_IS_JOB_FONTS (job)) {
+ retval = remove_job_from_queue_locked (fonts_queue, job);
+ } else if (EV_IS_JOB_PRINT (job)) {
+ retval = remove_job_from_queue_locked (print_queue, job);
} else {
g_assert_not_reached ();
}