mirror of
https://github.com/libretro/RetroArch
synced 2025-03-29 22:20:21 +00:00
Create TASK_CTL_INIT
This commit is contained in:
parent
b008750f18
commit
a5e8615091
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user