From e71d27db284ccf431167816167bf72f1e23c334d Mon Sep 17 00:00:00 2001 From: Carlos Garcia Campos Date: Sun, 03 Aug 2008 11:01:28 +0000 Subject: Rework the jobs system in order to make it simpler and more extensible. It 2008-08-03 Carlos Garcia Campos * libdocument/ev-document.[ch]: (ev_document_doc_mutex_trylock), (ev_document_fc_mutex_trylock): * shell/Makefile.am: * shell/ev-job-queue.[ch]: * shell/ev-job-scheduler.[ch]: * shell/ev-jobs.[ch]: (ev_job_init), (ev_job_dispose), (ev_job_class_init), (emit_finished), (ev_job_emit_finished), (ev_job_run), (ev_job_cancel), (ev_job_failed), (ev_job_failed_from_error), (ev_job_succeeded), (ev_job_is_finished), (ev_job_is_failed), (ev_job_get_run_mode), (ev_job_set_run_mode), (ev_job_links_init), (ev_job_links_run), (ev_job_links_class_init), (ev_job_render_init), (notify_page_ready), (ev_job_render_page_ready), (ev_job_render_run), (ev_job_render_class_init), (ev_job_thumbnail_init), (ev_job_thumbnail_run), (ev_job_thumbnail_class_init), (ev_job_fonts_init), (ev_job_fonts_run), (ev_job_fonts_class_init), (ev_job_load_init), (ev_job_load_run), (ev_job_load_class_init), (ev_job_save_init), (ev_job_save_dispose), (ev_job_save_run), (ev_job_save_class_init), (ev_job_print_init), (ev_job_print_dispose), (ev_job_print_run), (ev_job_print_class_init): * shell/ev-page-cache.c: * shell/ev-pixbuf-cache.[ch]: (dispose_cache_job_info), (check_job_size_and_unref), (move_one_job), (copy_job_to_job_info), (add_job), (ev_pixbuf_cache_add_jobs_if_needed): * shell/ev-properties-fonts.c: (ev_properties_fonts_dispose), (job_fonts_finished_cb), (job_fonts_updated_cb), (ev_properties_fonts_set_document): * shell/ev-sidebar-links.c: (ev_sidebar_links_dispose), (ev_sidebar_links_set_document): * shell/ev-sidebar-thumbnails.c: (clear_range), (add_range), (ev_sidebar_thumbnails_set_document), (ev_sidebar_thumbnails_clear_job): * shell/ev-view-private.h: * shell/ev-view.c: * shell/ev-window.c: (ev_window_clear_thumbnail_job), (ev_window_refresh_window_thumbnail), (password_dialog_response), (ev_window_clear_load_job), (ev_window_clear_reload_job), (ev_window_load_job_cb), (ev_window_reload_job_cb), (window_open_file_copy_ready_cb), (ev_window_open_uri), (ev_window_reload_document), (ev_window_clear_save_job), (ev_window_save_job_cb), (file_save_dialog_response_cb), (ev_window_clear_print_job), (ev_window_print_job_cb), (ev_window_print_dialog_response_cb): * shell/main.c: (main): Rework the jobs system in order to make it simpler and more extensible. It allows to run jobs in the main loop instead of using a thread when it's appropriate like the fonts job. Now it's also possible to cancel jobs that are currently running. svn path=/trunk/; revision=3092 --- (limited to 'shell/ev-pixbuf-cache.c') diff --git a/shell/ev-pixbuf-cache.c b/shell/ev-pixbuf-cache.c index 25b6f2c..91c2478 100644 --- a/shell/ev-pixbuf-cache.c +++ b/shell/ev-pixbuf-cache.c @@ -1,6 +1,6 @@ #include #include "ev-pixbuf-cache.h" -#include "ev-job-queue.h" +#include "ev-job-scheduler.h" #include "ev-page-cache.h" #include "ev-document-images.h" #include "ev-document-forms.h" @@ -163,8 +163,8 @@ dispose_cache_job_info (CacheJobInfo *job_info, g_signal_handlers_disconnect_by_func (job_info->job, G_CALLBACK (job_finished_cb), data); - ev_job_queue_remove_job (job_info->job); - g_object_unref (G_OBJECT (job_info->job)); + ev_job_cancel (job_info->job); + g_object_unref (job_info->job); job_info->job = NULL; } if (job_info->surface) { @@ -313,7 +313,7 @@ check_job_size_and_unref (EvPixbufCache *pixbuf_cache, g_signal_handlers_disconnect_by_func (job_info->job, G_CALLBACK (job_finished_cb), pixbuf_cache); - ev_job_queue_remove_job (job_info->job); + ev_job_cancel (job_info->job); g_object_unref (job_info->job); job_info->job = NULL; } @@ -330,11 +330,11 @@ move_one_job (CacheJobInfo *job_info, CacheJobInfo *new_next_job, int start_page, int end_page, - EvJobPriority priority) + gint priority) { CacheJobInfo *target_page = NULL; int page_offset; - EvJobPriority new_priority; + gint new_priority; if (page < (start_page - pixbuf_cache->preload_cache_size) || page > (end_page + pixbuf_cache->preload_cache_size)) { @@ -361,7 +361,7 @@ move_one_job (CacheJobInfo *job_info, page_offset = page - start_page; g_assert (page_offset >= 0 && page_offset <= ((end_page - start_page) + 1)); - new_priority = EV_JOB_PRIORITY_HIGH; + new_priority = EV_JOB_PRIORITY_URGENT; target_page = new_job_list + page_offset; } @@ -374,7 +374,7 @@ move_one_job (CacheJobInfo *job_info, job_info->form_field_mapping = NULL; if (new_priority != priority && target_page->job) { - ev_job_queue_update_job (target_page->job, new_priority); + ev_job_scheduler_update_job (target_page->job, new_priority); } } @@ -421,7 +421,7 @@ ev_pixbuf_cache_update_range (EvPixbufCache *pixbuf_cache, move_one_job (pixbuf_cache->job_list + i, pixbuf_cache, page, new_job_list, new_prev_job, new_next_job, - start_page, end_page, EV_JOB_PRIORITY_HIGH); + start_page, end_page, EV_JOB_PRIORITY_URGENT); page ++; } @@ -529,8 +529,8 @@ copy_job_to_job_info (EvJobRender *job_render, g_signal_handlers_disconnect_by_func (job_info->job, G_CALLBACK (job_finished_cb), pixbuf_cache); - ev_job_queue_remove_job (job_info->job); - g_object_unref (G_OBJECT (job_info->job)); + ev_job_cancel (job_info->job); + g_object_unref (job_info->job); job_info->job = NULL; } } @@ -647,13 +647,13 @@ add_job (EvPixbufCache *pixbuf_cache, text, base); } - ev_job_queue_add_job (job_info->job, priority); g_signal_connect (G_OBJECT (job_info->job), "page-ready", G_CALLBACK (job_page_ready_cb), pixbuf_cache); g_signal_connect (G_OBJECT (job_info->job), "finished", G_CALLBACK (job_finished_cb), pixbuf_cache); + ev_job_scheduler_push_job (job_info->job, priority); } static void @@ -701,7 +701,7 @@ ev_pixbuf_cache_add_jobs_if_needed (EvPixbufCache *pixbuf_cache, add_job_if_needed (pixbuf_cache, job_info, page_cache, page, rotation, scale, - EV_JOB_PRIORITY_HIGH); + EV_JOB_PRIORITY_URGENT); } for (i = FIRST_VISABLE_PREV(pixbuf_cache); i < pixbuf_cache->preload_cache_size; i++) { @@ -1235,7 +1235,7 @@ ev_pixbuf_cache_reload_page (EvPixbufCache *pixbuf_cache, add_job (pixbuf_cache, job_info, page_cache, region, width, height, page, rotation, scale, - EV_JOB_PRIORITY_HIGH); + EV_JOB_PRIORITY_URGENT); } -- cgit v0.9.1