From d33f0b5239376070d1a99b607d59f228f371c58f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 6 Dec 2015 18:37:57 +0100 Subject: [PATCH] Don't make async_jobs dependent on global state anymore --- cheevos.c | 13 ++++++++----- frontend/frontend.c | 19 +++++++++++++++---- runloop.h | 6 ------ 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/cheevos.c b/cheevos.c index 63c6853224..3157579c4e 100644 --- a/cheevos.c +++ b/cheevos.c @@ -34,7 +34,6 @@ #include "verbosity.h" - enum { CHEEVOS_VAR_SIZE_BIT_0, @@ -175,6 +174,10 @@ cheevos_globals_t cheevos_globals = 0 }; +/* forward declaration */ + +int rarch_main_async_job_add(async_task_t task, void *payload); + /***************************************************************************** Supporting functions. *****************************************************************************/ @@ -1245,7 +1248,7 @@ static void cheevos_unlocker(void *payload) else { RARCH_LOG("CHEEVOS error awarding achievement %u, will retry\n", cheevo_id); - async_job_add(global->async_jobs, cheevos_unlocker, (void*)(uintptr_t)cheevo_id); + rarch_main_async_job_add(cheevos_unlocker, (void*)(uintptr_t)cheevo_id); } } } @@ -1266,7 +1269,7 @@ static void cheevos_test_cheevo_set(const cheevoset_t *set) rarch_main_msg_queue_push(cheevo->title, 0, 3 * 60, false); rarch_main_msg_queue_push(cheevo->description, 0, 5 * 60, false); - async_job_add(global->async_jobs, cheevos_unlocker, (void*)(uintptr_t)cheevo->id); + rarch_main_async_job_add(cheevos_unlocker, (void*)(uintptr_t)cheevo->id); cheevo->active = 0; } @@ -1435,7 +1438,7 @@ static void cheevos_playing(void *payload) else { RARCH_LOG("CHEEVOS error posting playing game %u activity, will retry\n", game_id); - async_job_add(global->async_jobs, cheevos_playing, (void*)(uintptr_t)game_id); + rarch_main_async_job_add(cheevos_playing, (void*)(uintptr_t)game_id); } } } @@ -1915,7 +1918,7 @@ int cheevos_load(const struct retro_game_info *info) free((void*)json); cheevos_locals.loaded = 1; - async_job_add(global->async_jobs, cheevos_playing, (void*)(uintptr_t)game_id); + rarch_main_async_job_add(cheevos_playing, (void*)(uintptr_t)game_id); return 0; } diff --git a/frontend/frontend.c b/frontend/frontend.c index 3e778f8cca..028b9c50ad 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -18,7 +18,10 @@ #include #include #include + +#ifdef HAVE_THREADS #include +#endif #include "frontend.h" #include "../ui/ui_companion_driver.h" @@ -37,6 +40,15 @@ #define MAX_ARGS 32 +#ifdef HAVE_THREADS +static async_job_t *async_jobs; + +int rarch_main_async_job_add(async_task_t task, void *payload) +{ + return async_job_add(async_jobs, task, payload); +} +#endif + /** * main_exit: * @@ -258,8 +270,7 @@ int rarch_main(int argc, char *argv[], void *data) rarch_main_new(); #ifdef HAVE_THREADS - global = global_get_ptr(); - global->async_jobs = async_job_new(); + async_jobs = async_job_new(); #endif if (frontend_driver_is_inited()) @@ -306,8 +317,8 @@ int rarch_main(int argc, char *argv[], void *data) #endif #ifdef HAVE_THREADS - async_job_free(global->async_jobs); - global->async_jobs = NULL; + async_job_free(async_jobs); + async_jobs = NULL; #endif return 0; diff --git a/runloop.h b/runloop.h index b786e6945b..8b1108f6e5 100644 --- a/runloop.h +++ b/runloop.h @@ -16,8 +16,6 @@ #ifndef __RETROARCH_RUNLOOP_H #define __RETROARCH_RUNLOOP_H -#include - #include "libretro.h" #include "core_info.h" #include "core_options.h" @@ -272,10 +270,6 @@ typedef struct global bool softfilter_enable; } console; -#ifdef HAVE_THREADS - async_job_t *async_jobs; -#endif - struct { bool main;