Anna Schumaker
779969f28b
The thread pool is used to fetch album art in the background, but this can slow down most tests that aren't interested in album art. Adding a (testing-only) function for running without the thread pool speeds things up a bit. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
48 lines
1.4 KiB
C
48 lines
1.4 KiB
C
/*
|
|
* Copyright 2013 (c) Anna Schumaker.
|
|
*
|
|
* The idle queue is used to schedule function calls to run at a
|
|
* later time. It is expected that a higher layer can determine
|
|
* when the application is idle and call idle_run_task() accordingly.
|
|
*
|
|
* The idle layer keeps a count of the number of tasks added to the queue
|
|
* since the last time the queue was empty. Whenever a task is scheduled,
|
|
* the "queued" count is incremented by 1. When tasks are run, the "serviced"
|
|
* count is incremented by 1. These counters are reset to 0 once the queue
|
|
* is empty.
|
|
*/
|
|
#ifndef OCARINA_CORE_IDLE_H
|
|
#define OCARINA_CORE_IDLE_H
|
|
#include <stdbool.h>
|
|
|
|
enum idle_sync_t {
|
|
IDLE_SYNC, /* Run task in the main thread. */
|
|
IDLE_ASYNC, /* Run task in a separate thread. */
|
|
};
|
|
|
|
#define IDLE_FUNC(x) ((bool (*)(void *))x)
|
|
|
|
|
|
/* Called to initialize the idle queue. */
|
|
void idle_init();
|
|
#ifdef CONFIG_TESTING
|
|
void idle_init_sync();
|
|
#endif /* CONFIG_TESTING */
|
|
|
|
/* Called to deinitialize the idle queue. */
|
|
void idle_deinit();
|
|
|
|
/* Called to schedule a function to run later. */
|
|
void idle_schedule(enum idle_sync_t, bool (*)(void *), void *);
|
|
|
|
/*
|
|
* 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();
|
|
|
|
#endif /* OCARINA_CORE_IDLE_H */
|