X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=shell%2Fev-job-queue.c;h=bd7b86c55a026231eec264fe63dc1ce9d5cd57a6;hb=c8e5475fea2b7a92f935e4ae69994fdaf95da2bd;hp=a860f377f39b2d30a572c5bbc1c967ca0e526756;hpb=cbdeaed3897f8fdd01995a356c1e3a829fffbf7e;p=evince.git diff --git a/shell/ev-job-queue.c b/shell/ev-job-queue.c index a860f377..bd7b86c5 100644 --- a/shell/ev-job-queue.c +++ b/shell/ev-job-queue.c @@ -13,8 +13,8 @@ static GQueue *render_queue_low = NULL; static GQueue *thumbnail_queue_high = NULL; static GQueue *thumbnail_queue_low = NULL; static GQueue *load_queue = NULL; -static GQueue *xfer_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 */ @@ -52,6 +52,14 @@ add_job_to_async_queue (GQueue *queue, EvJob *job) 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) @@ -61,6 +69,14 @@ add_job_to_queue_locked (GQueue *queue, 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) { @@ -69,6 +85,13 @@ 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) { @@ -77,6 +100,14 @@ 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) { @@ -98,12 +129,12 @@ 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_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. */ @@ -114,6 +145,24 @@ handle_job (EvJob *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) { @@ -139,21 +188,30 @@ search_for_jobs_unlocked (void) if (job) return job; - job = (EvJob *) g_queue_pop_head (xfer_queue); + job = (EvJob *) g_queue_pop_head (thumbnail_queue_low); if (job) return job; - job = (EvJob *) g_queue_pop_head (thumbnail_queue_low); + job = (EvJob *) g_queue_pop_head (fonts_queue); if (job) return job; - job = (EvJob *) g_queue_pop_head (fonts_queue); + 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) { @@ -161,13 +219,23 @@ 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 (thumbnail_queue_high) && g_queue_is_empty (thumbnail_queue_low) - && g_queue_is_empty (fonts_queue); + && 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) { @@ -192,6 +260,12 @@ 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) { @@ -211,6 +285,12 @@ 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) { @@ -221,7 +301,6 @@ ev_job_queue_init (void) links_queue = g_queue_new (); load_queue = g_queue_new (); - xfer_queue = g_queue_new (); render_queue_high = g_queue_new (); render_queue_low = g_queue_new (); async_render_queue_high = g_queue_new (); @@ -229,6 +308,7 @@ ev_job_queue_init (void) 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); @@ -259,15 +339,15 @@ find_queue (EvJob *job, } 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_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; } } @@ -405,10 +485,10 @@ ev_job_queue_remove_job (EvJob *job) 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_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 (); }