From fe18abe0b3173d2d12075756170d6b63cd331747 Mon Sep 17 00:00:00 2001 From: Jonathan Blandford Date: Sat, 09 Apr 2005 05:06:17 +0000 Subject: Actually fix the "FIXME: update priority" comment. Sat Apr 9 01:05:09 2005 Jonathan Blandford * shell/ev-pixbuf-cache.c (move_one_job): Actually fix the "FIXME: update priority" comment. * backend/ev-job-queue.c: Give a way to change priority. --- diff --git a/ChangeLog b/ChangeLog index 3e9892a..59b1ca9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Sat Apr 9 01:05:09 2005 Jonathan Blandford + + * shell/ev-pixbuf-cache.c (move_one_job): Actually fix the "FIXME: + update priority" comment. + + * backend/ev-job-queue.c: Give a way to change priority. + Sat Apr 9 00:05:36 2005 Jonathan Blandford * shell/ev-page-action.c: Fix logic. diff --git a/backend/ev-job-queue.c b/backend/ev-job-queue.c index 4bd824f..72470ee 100644 --- a/backend/ev-job-queue.c +++ b/backend/ev-job-queue.c @@ -14,7 +14,7 @@ static GQueue *thumbnail_queue_high = NULL; static GQueue *thumbnail_queue_low = NULL; static gboolean -remove_object_from_queue (GQueue *queue, EvJob *job) +remove_job_from_queue_locked (GQueue *queue, EvJob *job) { GList *list; @@ -28,6 +28,15 @@ remove_object_from_queue (GQueue *queue, EvJob *job) return FALSE; } +static void +add_job_to_queue_locked (GQueue *queue, + EvJob *job) +{ + g_object_ref (job); + g_queue_push_tail (queue, job); + g_cond_broadcast (render_cond); +} + static gboolean notify_finished (GObject *job) @@ -173,13 +182,52 @@ ev_job_queue_add_job (EvJob *job, queue = find_queue (job, priority); g_mutex_lock (ev_queue_mutex); + add_job_to_queue_locked (queue, job); + g_mutex_unlock (ev_queue_mutex); +} - g_object_ref (job); - g_queue_push_tail (queue, job); - g_cond_broadcast (render_cond); +gboolean +ev_job_queue_update_job (EvJob *job, + EvJobPriority new_priority) +{ + gboolean retval = FALSE; + + g_return_val_if_fail (EV_IS_JOB (job), FALSE); - g_mutex_unlock (ev_queue_mutex); + g_mutex_lock (ev_queue_mutex); + g_object_ref (job); + if (EV_IS_JOB_THUMBNAIL (job)) { + if (new_priority == EV_JOB_PRIORITY_LOW) { + if (remove_job_from_queue_locked (thumbnail_queue_high, job)) { + add_job_to_queue_locked (thumbnail_queue_low, job); + retval = TRUE; + } + } else if (new_priority == EV_JOB_PRIORITY_HIGH) { + if (remove_job_from_queue_locked (thumbnail_queue_low, job)) { + add_job_to_queue_locked (thumbnail_queue_high, job); + retval = TRUE; + } + } + } else if (EV_IS_JOB_RENDER (job)) { + if (new_priority == EV_JOB_PRIORITY_LOW) { + if (remove_job_from_queue_locked (render_queue_high, job)) { + add_job_to_queue_locked (render_queue_low, job); + retval = TRUE; + } + } else if (new_priority == EV_JOB_PRIORITY_HIGH) { + if (remove_job_from_queue_locked (render_queue_low, job)) { + add_job_to_queue_locked (render_queue_high, job); + retval = TRUE; + } + } + } else { + /* We don't have a priority queue for any of the other jobs */ + } + g_object_unref (job); + g_mutex_unlock (ev_queue_mutex); + + return retval; } gboolean @@ -192,13 +240,13 @@ ev_job_queue_remove_job (EvJob *job) g_mutex_lock (ev_queue_mutex); if (EV_IS_JOB_THUMBNAIL (job)) { - retval = remove_object_from_queue (thumbnail_queue_high, job); - retval = retval || remove_object_from_queue (thumbnail_queue_low, job); + retval = remove_job_from_queue_locked (thumbnail_queue_high, job); + retval = retval || remove_job_from_queue_locked (thumbnail_queue_low, job); } else if (EV_IS_JOB_RENDER (job)) { - retval = remove_object_from_queue (render_queue_high, job); - retval = retval || remove_object_from_queue (render_queue_low, job); + retval = remove_job_from_queue_locked (render_queue_high, job); + retval = retval || remove_job_from_queue_locked (render_queue_low, job); } else if (EV_IS_JOB_LINKS (job)) { - retval = remove_object_from_queue (links_queue, job); + retval = remove_job_from_queue_locked (links_queue, job); } else { g_assert_not_reached (); } diff --git a/backend/ev-job-queue.h b/backend/ev-job-queue.h index ec93389..e6e4c0e 100644 --- a/backend/ev-job-queue.h +++ b/backend/ev-job-queue.h @@ -30,6 +30,8 @@ void ev_job_queue_init (void); void ev_job_queue_add_job (EvJob *job, EvJobPriority priority); +gboolean ev_job_queue_update_job (EvJob *job, + EvJobPriority new_priority); gboolean ev_job_queue_remove_job (EvJob *job); G_END_DECLS diff --git a/shell/ev-pixbuf-cache.c b/shell/ev-pixbuf-cache.c index 7200b37..91bd314 100644 --- a/shell/ev-pixbuf-cache.c +++ b/shell/ev-pixbuf-cache.c @@ -284,7 +284,7 @@ move_one_job (CacheJobInfo *job_info, job_info->link_mapping = NULL; if (new_priority != priority && target_page->job) { - g_print ("FIXME: update priority \n"); + ev_job_queue_update_job (target_page->job, new_priority); } } -- cgit v0.9.1