Remove configuration.h dependencies from tasks.c

This commit is contained in:
twinaphex 2016-02-09 17:41:19 +01:00
parent a12e307039
commit 0378463130
6 changed files with 50 additions and 17 deletions

View File

@ -53,6 +53,8 @@
#include "../config.def.h" #include "../config.def.h"
#include "../performance.h" #include "../performance.h"
#include "../tasks/tasks_internal.h"
struct rarch_setting_info struct rarch_setting_info
{ {
@ -2821,6 +2823,14 @@ void general_write_handler(void *data)
switch (hash) switch (hash)
{ {
case MENU_LABEL_VIDEO_THREADED:
{
if (*setting->value.boolean)
task_ctl(TASK_CTL_SET_THREADED, NULL);
else
task_ctl(TASK_CTL_UNSET_THREADED, NULL);
}
break;
case MENU_LABEL_INPUT_POLL_TYPE_BEHAVIOR: case MENU_LABEL_INPUT_POLL_TYPE_BEHAVIOR:
core_ctl(CORE_CTL_SET_POLL_TYPE, setting->value.integer); core_ctl(CORE_CTL_SET_POLL_TYPE, setting->value.integer);
break; break;

View File

@ -1205,7 +1205,8 @@ static int rarch_main_init(int argc, char *argv[])
rarch_ctl(RARCH_CTL_VALIDATE_CPU_FEATURES, NULL); rarch_ctl(RARCH_CTL_VALIDATE_CPU_FEATURES, NULL);
config_load(); config_load();
task_ctl(TASK_CTL_INIT, NULL);
runloop_ctl(RUNLOOP_CTL_TASK_INIT, NULL);
{ {
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();

View File

@ -970,12 +970,18 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
slock_unlock(runloop_msg_queue_lock); slock_unlock(runloop_msg_queue_lock);
#endif #endif
break; break;
case RUNLOOP_CTL_TASK_INIT:
{
bool threaded_enable = settings->threaded_data_runloop_enable;
task_ctl(TASK_CTL_INIT, &threaded_enable);
}
break;
case RUNLOOP_CTL_PREPARE_DUMMY: case RUNLOOP_CTL_PREPARE_DUMMY:
#ifdef HAVE_MENU #ifdef HAVE_MENU
menu_driver_ctl(RARCH_MENU_CTL_UNSET_LOAD_NO_CONTENT, NULL); menu_driver_ctl(RARCH_MENU_CTL_UNSET_LOAD_NO_CONTENT, NULL);
#endif #endif
runloop_ctl(RUNLOOP_CTL_DATA_DEINIT, NULL); runloop_ctl(RUNLOOP_CTL_DATA_DEINIT, NULL);
task_ctl(TASK_CTL_INIT, NULL); runloop_ctl(RUNLOOP_CTL_TASK_INIT, NULL);
runloop_ctl(RUNLOOP_CTL_CLEAR_CONTENT_PATH, NULL); runloop_ctl(RUNLOOP_CTL_CLEAR_CONTENT_PATH, NULL);
rarch_ctl(RARCH_CTL_LOAD_CONTENT, NULL); rarch_ctl(RARCH_CTL_LOAD_CONTENT, NULL);

View File

@ -33,6 +33,7 @@ enum runloop_ctl_state
RUNLOOP_CTL_SHOULD_SET_FRAME_LIMIT, RUNLOOP_CTL_SHOULD_SET_FRAME_LIMIT,
RUNLOOP_CTL_SET_FRAME_TIME_LAST, RUNLOOP_CTL_SET_FRAME_TIME_LAST,
RUNLOOP_CTL_UNSET_FRAME_TIME_LAST, RUNLOOP_CTL_UNSET_FRAME_TIME_LAST,
RUNLOOP_CTL_TASK_INIT,
RUNLOOP_CTL_IS_FRAME_TIME_LAST, RUNLOOP_CTL_IS_FRAME_TIME_LAST,
RUNLOOP_CTL_IS_FRAME_COUNT_END, RUNLOOP_CTL_IS_FRAME_COUNT_END,
RUNLOOP_CTL_IS_IDLE, RUNLOOP_CTL_IS_IDLE,

View File

@ -18,10 +18,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
#ifdef HAVE_THREADS
#include "../configuration.h"
#endif
#include "tasks.h" #include "tasks.h"
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
@ -337,9 +333,7 @@ static struct rarch_task_impl impl_threaded = {
bool task_ctl(enum task_ctl_state state, void *data) bool task_ctl(enum task_ctl_state state, void *data)
{ {
static struct rarch_task_impl *impl_current = NULL; static struct rarch_task_impl *impl_current = NULL;
#ifdef HAVE_THREADS static bool task_threaded_enable = false;
settings_t *settings = config_get_ptr();
#endif
switch (state) switch (state)
{ {
@ -348,14 +342,29 @@ bool task_ctl(enum task_ctl_state state, void *data)
impl_current->deinit(); impl_current->deinit();
impl_current = NULL; impl_current = NULL;
break; break;
case TASK_CTL_SET_THREADED:
task_threaded_enable = true;
break;
case TASK_CTL_UNSET_THREADED:
task_threaded_enable = false;
break;
case TASK_CTL_IS_THREADED:
return task_threaded_enable;
case TASK_CTL_INIT: case TASK_CTL_INIT:
impl_current = &impl_regular; {
bool *boolean_val = (bool*)data;
impl_current = &impl_regular;
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
if (settings->threaded_data_runloop_enable) if (*boolean_val)
impl_current = &impl_threaded; {
task_ctl(TASK_CTL_SET_THREADED, NULL);
impl_current = &impl_threaded;
}
#endif #endif
impl_current->init(); impl_current->init();
}
break; break;
case TASK_CTL_FIND: case TASK_CTL_FIND:
{ {
@ -368,7 +377,7 @@ bool task_ctl(enum task_ctl_state state, void *data)
{ {
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
bool current_threaded = (impl_current == &impl_threaded); bool current_threaded = (impl_current == &impl_threaded);
bool want_threaded = settings->threaded_data_runloop_enable; bool want_threaded = task_ctl(TASK_CTL_IS_THREADED, NULL);
if (want_threaded != current_threaded) if (want_threaded != current_threaded)
task_ctl(TASK_CTL_DEINIT, NULL); task_ctl(TASK_CTL_DEINIT, NULL);
@ -382,8 +391,8 @@ bool task_ctl(enum task_ctl_state state, void *data)
break; break;
case TASK_CTL_PUSH: case TASK_CTL_PUSH:
{ {
/* The lack of NULL checks in the following functions is proposital /* The lack of NULL checks in the following functions
* to ensure correct control flow by the users. */ * is proposital to ensure correct control flow by the users. */
rarch_task_t *task = (rarch_task_t*)data; rarch_task_t *task = (rarch_task_t*)data;
impl_current->push_running(task); impl_current->push_running(task);
break; break;

View File

@ -70,7 +70,13 @@ enum task_ctl_state
* They will finish as soon as possible. * They will finish as soon as possible.
* *
* This must only be called from the main thread. */ * This must only be called from the main thread. */
TASK_CTL_RESET TASK_CTL_RESET,
TASK_CTL_SET_THREADED,
TASK_CTL_UNSET_THREADED,
TASK_CTL_IS_THREADED
}; };
typedef struct rarch_task rarch_task_t; typedef struct rarch_task rarch_task_t;