From 8e25c4d89e341d48bfcb57be9d522d2810a21190 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Tue, 10 Nov 2015 13:56:54 -0500 Subject: [PATCH] core/idle: Move idle_run_task() out of the idle queue Signed-off-by: Anna Schumaker --- core/idle.cpp | 2 +- gui/manager.cpp | 2 +- include/core/idle.h | 15 ++++++--------- tests/core/idle.cpp | 6 +++--- tests/core/library.cpp | 12 ++++++------ 5 files changed, 17 insertions(+), 20 deletions(-) diff --git a/core/idle.cpp b/core/idle.cpp index c5ef914c..40a3a462 100644 --- a/core/idle.cpp +++ b/core/idle.cpp @@ -24,7 +24,7 @@ void idle :: IdleBase :: schedule() } -bool idle :: run_task() +bool idle_run_task() { if (idle_queue.size() > 0) { idle_queue.front()->run(); diff --git a/gui/manager.cpp b/gui/manager.cpp index adc8b00d..62755092 100644 --- a/gui/manager.cpp +++ b/gui/manager.cpp @@ -105,7 +105,7 @@ static void remove_banned_tracks() static bool on_idle() { - bool ret = idle :: run_task(); + bool ret = idle_run_task(); if (ret) { c_progress->show(); diff --git a/include/core/idle.h b/include/core/idle.h index 75c2bb73..6e1c3e97 100644 --- a/include/core/idle.h +++ b/include/core/idle.h @@ -75,18 +75,15 @@ namespace idle new IdleTask(func, data); } - /** - * Run the next task on the idle queue and increment the "serviced" - * counter. If this was the last task then the "queued" and - * "serviced" values are reset to 0. - * - * @return True if there are still tasks on the queue, false otherwise. - */ - bool run_task(); - }; +/* + * Called to run the next task on the idle queue. + * Returns true if there are more tasks to run. + */ +bool idle_run_task(); + /* Called to find the percentage of idle tasks that have been run. */ float idle_progress(); diff --git a/tests/core/idle.cpp b/tests/core/idle.cpp index fa1f43c6..fa1c6bb9 100644 --- a/tests/core/idle.cpp +++ b/tests/core/idle.cpp @@ -21,19 +21,19 @@ static void test_idle_queue(unsigned int n) cur = -1; test_equal(idle_progress(), (float)1.0); - test_equal(idle :: run_task(), false); + test_equal(idle_run_task(), false); for (float i = 0; i < n; i++) idle :: schedule(inc_cur, i); test_equal(idle_progress(), (float)0.0); for (unsigned int i = 0; i < (n - 1); i++) { - test_loop_equal(idle :: run_task(), true, i); + test_loop_equal(idle_run_task(), true, i); test_loop_equal(idle_progress(), ((i + 1) / (float)n), i); test_loop_equal(func_passed, true, i); } test_loop_passed(); - test_equal(idle :: run_task(), false); + test_equal(idle_run_task(), false); test_equal(idle_progress(), (float)1.0); } diff --git a/tests/core/library.cpp b/tests/core/library.cpp index 59ca465e..6df7713e 100644 --- a/tests/core/library.cpp +++ b/tests/core/library.cpp @@ -75,11 +75,11 @@ static void test_add() collection :: add("/tmp/ocarina/"); test_equal(q->size(), (unsigned)0); - test_equal(idle :: run_task(), true); + test_equal(idle_run_task(), true); test_equal(q->size(), (unsigned)0); for (unsigned int i = 0; i < 6; i++) { - test_equal(idle :: run_task(), (i < 5) ? true : false); + test_equal(idle_run_task(), (i < 5) ? true : false); test_equal(q->size(), i * 7); } } @@ -90,22 +90,22 @@ static void test_update() test_rm_library_dirs(); collection :: update_all(); - test_equal(idle :: run_task(), true); + test_equal(idle_run_task(), true); test_equal(q->size(), (unsigned)21); for (unsigned int i = 0; i < 4; i++) - test_equal(idle :: run_task(), (i < 3) ? true : false); + test_equal(idle_run_task(), (i < 3) ? true : false); test_equal(q->size(), (unsigned)21); test_generate_library(); collection :: update_all(); - test_equal(idle :: run_task(), true); + test_equal(idle_run_task(), true); test_equal(q->size(), (unsigned)21); for (unsigned int i = 0; i < 6; i++) - test_equal(idle :: run_task(), (i < 5) ? true : false); + test_equal(idle_run_task(), (i < 5) ? true : false); test_equal(q->size(), (unsigned)35); }