GNOME Bugzilla – Bug 751160
gtask does unnecessary work
Last modified: 2015-06-29 15:22:08 UTC
When a task is cancelled, gtask resorts the entire list of unprocessed items, when all we really want to do is move the cancelled task to the head of the queue. This is a problem in situation where the queue gets long, as can be seen in bug 751130
Created attachment 305593 [details] [review] Add async queue api
Created attachment 305594 [details] [review] Add threadpool api
Created attachment 305595 [details] [review] avoid resorting
Created attachment 305596 [details] [review] cleanup
Comment on attachment 305593 [details] [review] Add async queue api seems a bit weird to add _unlocked() versions without the corresponding un-unlocked ones? also, maybe test cases
Comment on attachment 305594 [details] [review] Add threadpool api not sure about the name, but ok
Comment on attachment 305595 [details] [review] avoid resorting ok
Comment on attachment 305596 [details] [review] cleanup yup
Created attachment 305838 [details] [review] Add async queue api
Created attachment 305839 [details] [review] Add tests
Created attachment 305840 [details] [review] Add threadpool api
Created attachment 305841 [details] [review] avoid resorting
Created attachment 305842 [details] [review] cleanup
Review of attachment 305840 [details] [review]: ::: docs/reference/glib/glib-sections.txt @@ +845,1 @@ g_async_queue_pop This hunk should be in the async queue patch
Comment on attachment 305838 [details] [review] Add async queue api > g_async_queue_push_sorted_unlocked >+g_async_queue_push_front_unlocked >+g_async_queue_remove_unlocked > g_async_queue_pop_unlocked need to add the non-_unlocked versions too >+ * g_async_queue_push_front: >+ * @queue: a #GAsyncQueue >+ * @data: @data to push into the @queue >+ * >+ * Pushes the @data into the @queue. @data must not be %NULL. >+ * In contrast to g_async_queue_push_unlocked(), this function "In contrast to g_async_queue_push()"
Comment on attachment 305839 [details] [review] Add tests >From e5893324b86878c4b580f66d91fd7f06b0666721 Mon Sep 17 00:00:00 2001 >From: Matthias Clasen <mclasen@redhat.com> >Date: Mon, 22 Jun 2015 11:35:06 -0400 >Subject: [PATCH 2/5] Add tests for new GAsyncQueue api > >--- > glib/tests/asyncqueue.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 48 insertions(+) > >diff --git a/glib/tests/asyncqueue.c b/glib/tests/asyncqueue.c >index 5ccbb23..4a81d23 100644 >--- a/glib/tests/asyncqueue.c >+++ b/glib/tests/asyncqueue.c >@@ -220,6 +220,52 @@ test_async_queue_timed (void) > g_async_queue_unref (q); > } > >+static void >+test_async_queue_remove (void) >+{ >+ GAsyncQueue *q; >+ >+ q = g_async_queue_new (); >+ >+ g_async_queue_push (q, GINT_TO_POINTER (10)); >+ g_async_queue_push (q, GINT_TO_POINTER (2)); >+ g_async_queue_push (q, GINT_TO_POINTER (7)); >+ g_async_queue_push (q, GINT_TO_POINTER (1)); >+ >+ g_async_queue_remove (q, GINT_TO_POINTER (7)); >+ >+ g_assert_cmpint (GPOINTER_TO_INT (g_async_queue_pop (q)), ==, 10); >+ g_assert_cmpint (GPOINTER_TO_INT (g_async_queue_pop (q)), ==, 2); >+ g_assert_cmpint (GPOINTER_TO_INT (g_async_queue_pop (q)), ==, 1); >+ >+ g_assert (g_async_queue_try_pop (q) == NULL); >+ >+ g_async_queue_unref (q); >+} >+ >+static void >+test_async_queue_push_front (void) >+{ >+ GAsyncQueue *q; >+ >+ q = g_async_queue_new (); >+ >+ g_async_queue_push (q, GINT_TO_POINTER (10)); >+ g_async_queue_push (q, GINT_TO_POINTER (2)); >+ g_async_queue_push (q, GINT_TO_POINTER (7)); >+ >+ g_async_queue_push_front (q, GINT_TO_POINTER (1)); >+ >+ g_assert_cmpint (GPOINTER_TO_INT (g_async_queue_pop (q)), ==, 1); >+ g_assert_cmpint (GPOINTER_TO_INT (g_async_queue_pop (q)), ==, 10); >+ g_assert_cmpint (GPOINTER_TO_INT (g_async_queue_pop (q)), ==, 2); >+ g_assert_cmpint (GPOINTER_TO_INT (g_async_queue_pop (q)), ==, 7); >+ >+ g_assert (g_async_queue_try_pop (q) == NULL); >+ >+ g_async_queue_unref (q); >+} >+ > int > main (int argc, char *argv[]) > { >@@ -229,6 +275,8 @@ main (int argc, char *argv[]) > g_test_add_func ("/asyncqueue/destroy", test_async_queue_destroy); > g_test_add_func ("/asyncqueue/threads", test_async_queue_threads); > g_test_add_func ("/asyncqueue/timed", test_async_queue_timed); >+ g_test_add_func ("/asyncqueue/remove", test_async_queue_remove); >+ g_test_add_func ("/asyncqueue/push_front", test_async_queue_push_front); > > return g_test_run (); > } >-- >2.4.3 >
Comment on attachment 305840 [details] [review] Add threadpool api good other than the part that was supposed to be in the other patch
Pushed with the reshuffled hunk, and the one doc reference fixup.