Create TASK_CTL_CHECK

This commit is contained in:
twinaphex 2016-01-28 09:45:14 +01:00
parent b807b89837
commit 7a5fbc6948
3 changed files with 26 additions and 30 deletions

View File

@ -454,7 +454,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
switch (state)
{
case RUNLOOP_CTL_DATA_ITERATE:
rarch_task_check();
task_ctl(TASK_CTL_CHECK, NULL);
return true;
case RUNLOOP_CTL_SHADER_DIR_DEINIT:
shader_dir_free(&runloop_shader_dir);

View File

@ -387,26 +387,6 @@ void rarch_task_deinit(void)
impl_current = NULL;
}
void rarch_task_check(void)
{
#ifdef HAVE_THREADS
settings_t *settings = config_get_ptr();
bool current_threaded = (impl_current == &impl_threaded);
bool want_threaded = settings->threaded_data_runloop_enable;
if (want_threaded != current_threaded)
{
RARCH_LOG("Switching rarch_task implementation.\n");
rarch_task_deinit();
}
if (impl_current == NULL)
rarch_task_init();
#endif
impl_current->gather();
}
bool rarch_task_find(rarch_task_finder_t func, void *user_data)
{
return impl_current->find(func, user_data);
@ -416,6 +396,26 @@ bool task_ctl(enum task_ctl_state state, void *data)
{
switch (state)
{
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;
if (want_threaded != current_threaded)
{
RARCH_LOG("Switching rarch_task implementation.\n");
rarch_task_deinit();
}
if (impl_current == NULL)
rarch_task_init();
#endif
impl_current->gather();
}
break;
case TASK_CTL_PUSH:
{
/* The lack of NULL checks in the following functions is proposital

View File

@ -33,6 +33,11 @@ enum task_ctl_state
* This must only be called from the main thread. */
TASK_CTL_WAIT,
/* Checks for finished tasks
* Takes the finished tasks, if any, and runs their callbacks.
* This must only be called from the main thread. */
TASK_CTL_CHECK,
/* Pushes a task
* The task will start as soon as possible. */
TASK_CTL_PUSH,
@ -105,15 +110,6 @@ void rarch_task_init(void);
*/
void rarch_task_deinit(void);
/**
* @brief Checks for finished tasks
*
* Takes the finished tasks, if any, and runs their callbacks.
*
* This function must only be called from the main thread.
*/
void rarch_task_check(void);
/**
* @brief Calls func for every running task until it returns true.
*