core/idle: Let tests run without the thread pool
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>
This commit is contained in:
parent
bd8f3754e7
commit
779969f28b
|
@ -1,4 +1,5 @@
|
||||||
6.4.16:
|
6.4.16:
|
||||||
|
- Let tests run without fetching album art
|
||||||
- Don't try to read data from nonexistant playlists
|
- Don't try to read data from nonexistant playlists
|
||||||
- Show hidden folders when selecting new images
|
- Show hidden folders when selecting new images
|
||||||
- Add preview widget to album art chooser dialog
|
- Add preview widget to album art chooser dialog
|
||||||
|
|
|
@ -14,7 +14,11 @@
|
||||||
|
|
||||||
void core_init(int *argc, char ***argv, struct core_init_data *init)
|
void core_init(int *argc, char ***argv, struct core_init_data *init)
|
||||||
{
|
{
|
||||||
|
#ifdef CONFIG_TESTING
|
||||||
|
idle_init_sync();
|
||||||
|
#else
|
||||||
idle_init();
|
idle_init();
|
||||||
|
#endif /* CONFIG_TESTING */
|
||||||
filter_init();
|
filter_init();
|
||||||
tags_init();
|
tags_init();
|
||||||
playlist_init(init->playlist_ops);
|
playlist_init(init->playlist_ops);
|
||||||
|
|
23
core/idle.c
23
core/idle.c
|
@ -17,13 +17,17 @@ static unsigned int queued = 0;
|
||||||
static unsigned int serviced = 0;
|
static unsigned int serviced = 0;
|
||||||
|
|
||||||
|
|
||||||
bool __idle_run_task(struct idle_task *task)
|
void __idle_free_task(struct idle_task *task)
|
||||||
{
|
{
|
||||||
bool finished = task->idle_func(task->idle_data);
|
|
||||||
if (finished) {
|
|
||||||
g_free(task);
|
g_free(task);
|
||||||
g_atomic_int_inc(&serviced);
|
g_atomic_int_inc(&serviced);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool __idle_run_task(struct idle_task *task)
|
||||||
|
{
|
||||||
|
bool finished = task->idle_func(task->idle_data);
|
||||||
|
if (finished)
|
||||||
|
__idle_free_task(task);
|
||||||
return finished;
|
return finished;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,6 +43,12 @@ void idle_init()
|
||||||
idle_pool = g_thread_pool_new(__idle_thread, NULL, 1, true, NULL);
|
idle_pool = g_thread_pool_new(__idle_thread, NULL, 1, true, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef CONFIG_TESTING
|
||||||
|
void idle_init_sync()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_TESTING */
|
||||||
|
|
||||||
void idle_deinit()
|
void idle_deinit()
|
||||||
{
|
{
|
||||||
struct idle_task *task;
|
struct idle_task *task;
|
||||||
|
@ -72,9 +82,12 @@ bool idle_run_task()
|
||||||
|
|
||||||
if (!g_queue_is_empty(&idle_queue)) {
|
if (!g_queue_is_empty(&idle_queue)) {
|
||||||
task = g_queue_pop_head(&idle_queue);
|
task = g_queue_pop_head(&idle_queue);
|
||||||
if (task->idle_sync == IDLE_ASYNC)
|
if (task->idle_sync == IDLE_ASYNC) {
|
||||||
|
if (idle_pool)
|
||||||
g_thread_pool_push(idle_pool, task, NULL);
|
g_thread_pool_push(idle_pool, task, NULL);
|
||||||
else if (!__idle_run_task(task))
|
else
|
||||||
|
__idle_free_task(task);
|
||||||
|
} else if (!__idle_run_task(task))
|
||||||
g_queue_push_tail(&idle_queue, task);
|
g_queue_push_tail(&idle_queue, task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,9 @@ enum idle_sync_t {
|
||||||
|
|
||||||
/* Called to initialize the idle queue. */
|
/* Called to initialize the idle queue. */
|
||||||
void idle_init();
|
void idle_init();
|
||||||
|
#ifdef CONFIG_TESTING
|
||||||
|
void idle_init_sync();
|
||||||
|
#endif /* CONFIG_TESTING */
|
||||||
|
|
||||||
/* Called to deinitialize the idle queue. */
|
/* Called to deinitialize the idle queue. */
|
||||||
void idle_deinit();
|
void idle_deinit();
|
||||||
|
|
|
@ -14,7 +14,7 @@ static void test_init()
|
||||||
struct queue *q = collection_get_queue();
|
struct queue *q = collection_get_queue();
|
||||||
GSList *list;
|
GSList *list;
|
||||||
|
|
||||||
idle_init();
|
idle_init_sync();
|
||||||
filter_init();
|
filter_init();
|
||||||
tags_init();
|
tags_init();
|
||||||
playlist_init(NULL);
|
playlist_init(NULL);
|
||||||
|
|
|
@ -14,7 +14,7 @@ static void test_init()
|
||||||
{
|
{
|
||||||
struct queue *q = history_get_queue();
|
struct queue *q = history_get_queue();
|
||||||
|
|
||||||
idle_init();
|
idle_init_sync();
|
||||||
filter_init();
|
filter_init();
|
||||||
tags_init();
|
tags_init();
|
||||||
playlist_init(NULL);
|
playlist_init(NULL);
|
||||||
|
|
|
@ -13,7 +13,7 @@ static void test_init()
|
||||||
struct library *library;
|
struct library *library;
|
||||||
GSList *list;
|
GSList *list;
|
||||||
|
|
||||||
idle_init();
|
idle_init_sync();
|
||||||
filter_init();
|
filter_init();
|
||||||
tags_init();
|
tags_init();
|
||||||
playlist_init(NULL);
|
playlist_init(NULL);
|
||||||
|
|
|
@ -53,7 +53,7 @@ static void test_init()
|
||||||
{
|
{
|
||||||
struct library *library;
|
struct library *library;
|
||||||
|
|
||||||
idle_init();
|
idle_init_sync();
|
||||||
filter_init();
|
filter_init();
|
||||||
tags_init();
|
tags_init();
|
||||||
pl_system_init(NULL);
|
pl_system_init(NULL);
|
||||||
|
|
|
@ -72,7 +72,7 @@ static void test_track()
|
||||||
gchar *date;
|
gchar *date;
|
||||||
|
|
||||||
setlocale(LC_TIME, "C");
|
setlocale(LC_TIME, "C");
|
||||||
idle_init();
|
idle_init_sync();
|
||||||
filter_init();
|
filter_init();
|
||||||
tags_init();
|
tags_init();
|
||||||
file_init(&f, "track_tag", 0, 0);
|
file_init(&f, "track_tag", 0, 0);
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
static void test_init()
|
static void test_init()
|
||||||
{
|
{
|
||||||
idle_init();
|
idle_init_sync();
|
||||||
filter_init();
|
filter_init();
|
||||||
tags_init();
|
tags_init();
|
||||||
playlist_init(NULL);
|
playlist_init(NULL);
|
||||||
|
|
Loading…
Reference in New Issue