core/idle: Move idle_progress() out of the idle namespace

Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
Anna Schumaker 2015-11-10 13:27:32 -05:00
parent cfd8ca8d43
commit f17a19fe57
4 changed files with 10 additions and 14 deletions

View File

@ -41,7 +41,7 @@ bool idle :: run_task()
return false;
}
float idle :: get_progress()
float idle_progress()
{
if (idle_queue.size() == 0)
return 1.0;

View File

@ -109,7 +109,7 @@ static bool on_idle()
if (ret) {
c_progress->show();
c_progress->set_fraction(idle :: get_progress());
c_progress->set_fraction(idle_progress());
} else
c_progress->hide();

View File

@ -84,16 +84,12 @@ namespace idle
*/
bool run_task();
/**
* Use the values of the queued and serviced counters to find the
* overall process of the idle queue (serviced / queued).
*
* @return The percentage of IdleTasks that have been run.
*/
float get_progress();
};
/* Called to find the percentage of idle tasks that have been run. */
float idle_progress();
#include "idle.hpp"
#endif /* OCARINA_CORE_IDLE_H */

View File

@ -20,21 +20,21 @@ static void test_idle_queue(unsigned int n)
{
cur = -1;
test_equal(idle :: get_progress(), (float)1.0);
test_equal(idle_progress(), (float)1.0);
test_equal(idle :: run_task(), false);
for (float i = 0; i < n; i++)
idle :: schedule(inc_cur, i);
test_equal(idle :: get_progress(), (float)0.0);
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 :: get_progress(), ((i + 1) / (float)n), 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 :: get_progress(), (float)1.0);
test_equal(idle_progress(), (float)1.0);
}