diff --git a/retroarch.c b/retroarch.c index ba96bd1173..476b56178c 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1223,7 +1223,7 @@ int rarch_main_init(int argc, char *argv[]) rarch_ctl(RARCH_CTL_VALIDATE_CPU_FEATURES, NULL); config_load(); - rarch_task_init(); + task_ctl(TASK_CTL_INIT, NULL); { settings_t *settings = config_get_ptr(); diff --git a/runloop.c b/runloop.c index 1848520e79..bedcff4d84 100644 --- a/runloop.c +++ b/runloop.c @@ -996,8 +996,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) menu_driver_ctl(RARCH_MENU_CTL_UNSET_LOAD_NO_CONTENT, NULL); #endif runloop_ctl(RUNLOOP_CTL_DATA_DEINIT, NULL); - rarch_task_init(); - + task_ctl(TASK_CTL_INIT, NULL); runloop_ctl(RUNLOOP_CTL_CLEAR_CONTENT_PATH, NULL); rarch_ctl(RARCH_CTL_LOAD_CONTENT, NULL); diff --git a/tasks/tasks.c b/tasks/tasks.c index c518bc060c..3839697b20 100644 --- a/tasks/tasks.c +++ b/tasks/tasks.c @@ -369,19 +369,6 @@ static struct rarch_task_impl impl_threaded = { }; #endif -void rarch_task_init(void) -{ -#ifdef HAVE_THREADS - settings_t *settings = config_get_ptr(); - if (settings->threaded_data_runloop_enable) - impl_current = &impl_threaded; - else -#endif - impl_current = &impl_regular; - - impl_current->init(); -} - bool rarch_task_find(rarch_task_finder_t func, void *user_data) { return impl_current->find(func, user_data); @@ -389,6 +376,10 @@ bool rarch_task_find(rarch_task_finder_t func, void *user_data) bool task_ctl(enum task_ctl_state state, void *data) { +#ifdef HAVE_THREADS + settings_t *settings = config_get_ptr(); +#endif + switch (state) { case TASK_CTL_DEINIT: @@ -398,10 +389,19 @@ bool task_ctl(enum task_ctl_state state, void *data) impl_current->deinit(); impl_current = NULL; break; + case TASK_CTL_INIT: +#ifdef HAVE_THREADS + if (settings->threaded_data_runloop_enable) + impl_current = &impl_threaded; + else +#endif + impl_current = &impl_regular; + + impl_current->init(); + break; case TASK_CTL_CHECK: { #ifdef HAVE_THREADS - settings_t *settings = config_get_ptr(); bool current_threaded = (impl_current == &impl_threaded); bool want_threaded = settings->threaded_data_runloop_enable; @@ -412,7 +412,7 @@ bool task_ctl(enum task_ctl_state state, void *data) } if (impl_current == NULL) - rarch_task_init(); + task_ctl(TASK_CTL_INIT, NULL); #endif impl_current->gather(); diff --git a/tasks/tasks.h b/tasks/tasks.h index 70d06a670c..a76d0e3ccf 100644 --- a/tasks/tasks.h +++ b/tasks/tasks.h @@ -36,6 +36,14 @@ enum task_ctl_state * until TASK_CTL_INIT is called again. */ TASK_CTL_DEINIT, + /* Initializes the task system. + * This initializes the task system + * and chooses an appropriate + * implementation according to the settings. + * + * This must only be called from the main thread. */ + TASK_CTL_INIT, + /* Blocks until all tasks have finished. * This must only be called from the main thread. */ TASK_CTL_WAIT, @@ -99,16 +107,6 @@ struct rarch_task rarch_task_t *next; }; -/** - * @brief Initializes the task system - * - * This function initializes the task system and chooses an appropriate - * implementation according to the settings. - * - * This function must only be called from the main thread. - */ -void rarch_task_init(void); - /** * @brief Calls func for every running task until it returns true. *