core/idle: Move idle_run_task() out of the idle queue
Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
f17a19fe57
commit
8e25c4d89e
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -75,18 +75,15 @@ namespace idle
|
|||
new IdleTask<T>(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();
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue