]> www.fi.muni.cz Git - evince.git/commitdiff
Actually fix the "FIXME: update priority" comment.
authorJonathan Blandford <jrb@redhat.com>
Sat, 9 Apr 2005 05:06:17 +0000 (05:06 +0000)
committerJonathan Blandford <jrb@src.gnome.org>
Sat, 9 Apr 2005 05:06:17 +0000 (05:06 +0000)
Sat Apr  9 01:05:09 2005  Jonathan Blandford  <jrb@redhat.com>

        * 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.

ChangeLog
backend/ev-job-queue.c
backend/ev-job-queue.h
shell/ev-pixbuf-cache.c

index 3e9892a1b0f3a08742345337e427ee200c26e1f8..59b1ca9c34d37f10feea01896a5cfc8ccde55b7c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Sat Apr  9 01:05:09 2005  Jonathan Blandford  <jrb@redhat.com>
+
+       * 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  <jrb@redhat.com>
 
        * shell/ev-page-action.c: Fix logic.
index 4bd824ff5001466d9059d68e728c23a09528ebfa..72470eef40c703bb4e79be7b83c3aaad8ad8b9ae 100644 (file)
@@ -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 ();
        }
index ec93389742badeeceeda27b78ef8b10d91983a00..e6e4c0ef6ee063f93e6ced387f5f8ef95981895c 100644 (file)
@@ -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
index 7200b37c4367982cf6e3952a295cb2b55b7a5148..91bd314588c2be029e837809fff8b59e7732bbd6 100644 (file)
@@ -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);
        }
 }