1
0
mirror of https://github.com/libretro/RetroArch synced 2024-07-08 12:15:49 +00:00

Move async job code to retroarch.c

This commit is contained in:
twinaphex 2016-05-17 14:40:04 +02:00
parent 146d2c8a1d
commit ce240dd47f
3 changed files with 26 additions and 27 deletions

View File

@ -270,7 +270,7 @@ static int cheats_were_enabled = 0;
/* forward declaration */
int rarch_main_async_job_add(async_task_t task, void *payload);
int retroarch_async_job_add(async_task_t task, void *payload);
/*****************************************************************************
Supporting functions.
@ -1444,7 +1444,7 @@ static void cheevos_unlocker(void *payload)
{
RARCH_ERR("CHEEVOS error awarding achievement %u, will retry...\n", cheevo_id);
/* re-schedule */
rarch_main_async_job_add(cheevos_unlocker, (void*)(uintptr_t)cheevo_id);
retroarch_async_job_add(cheevos_unlocker, (void*)(uintptr_t)cheevo_id);
}
}
}
@ -1463,7 +1463,7 @@ static void cheevos_test_cheevo_set(const cheevoset_t *set)
runloop_msg_queue_push(cheevo->title, 0, 3 * 60, false);
runloop_msg_queue_push(cheevo->description, 0, 5 * 60, false);
rarch_main_async_job_add(cheevos_unlocker,
retroarch_async_job_add(cheevos_unlocker,
(void*)(uintptr_t)cheevo->id);
cheevo->active = 0;
@ -1619,7 +1619,7 @@ static void cheevos_playing(void *payload)
{
RARCH_ERR("CHEEVOS error posting playing game %u activity, will retry\n", game_id);
/* re-schedule */
rarch_main_async_job_add(cheevos_playing, (void*)(uintptr_t)game_id);
retroarch_async_job_add(cheevos_playing, (void*)(uintptr_t)game_id);
}
}
}
@ -2142,7 +2142,7 @@ bool cheevos_load(const void *data)
free((void*)json);
cheevos_locals.loaded = 1;
rarch_main_async_job_add(cheevos_playing, (void*)(uintptr_t)game_id);
retroarch_async_job_add(cheevos_playing, (void*)(uintptr_t)game_id);
return true;
}

View File

@ -19,10 +19,6 @@
#include <retro_stat.h>
#include <queues/task_queue.h>
#ifdef HAVE_THREADS
#include <rthreads/async_job.h>
#endif
#include "frontend.h"
#include "../ui/ui_companion_driver.h"
#include "../tasks/tasks_internal.h"
@ -40,15 +36,6 @@
#include "../menu/menu_driver.h"
#endif
#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:
*
@ -111,10 +98,6 @@ int rarch_main(int argc, char *argv[], void *data)
rarch_ctl(RARCH_CTL_PREINIT, NULL);
frontend_driver_init_first(args);
rarch_ctl(RARCH_CTL_INIT, NULL);
#ifdef HAVE_THREADS
async_jobs = async_job_new();
#endif
if (frontend_driver_is_inited())
{
@ -152,11 +135,6 @@ int rarch_main(int argc, char *argv[], void *data)
main_exit(args);
#endif
#ifdef HAVE_THREADS
async_job_free(async_jobs);
async_jobs = NULL;
#endif
return 0;
}

View File

@ -26,6 +26,9 @@
#include <boolean.h>
#include <string/stdstring.h>
#include <lists/string_list.h>
#ifdef HAVE_THREADS
#include <rthreads/async_job.h>
#endif
#ifdef _WIN32
#ifdef _XBOX
@ -112,6 +115,10 @@ static char current_savefile_dir[PATH_MAX_LENGTH];
static char error_string[PATH_MAX_LENGTH];
static jmp_buf error_sjlj_context;
#ifdef HAVE_THREADS
static async_job_t *async_jobs;
#endif
#define _PSUPP(var, name, desc) printf(" %s:\n\t\t%s: %s\n", name, desc, _##var##_supp ? "yes" : "no")
static void retroarch_print_features(void)
@ -171,6 +178,13 @@ static void retroarch_print_features(void)
}
#undef _PSUPP
#ifdef HAVE_THREADS
int retroarch_async_job_add(async_task_t task, void *payload)
{
return async_job_add(async_jobs, task, payload);
}
#endif
static void retroarch_print_version(void)
{
char str[PATH_MAX_LENGTH] = {0};
@ -1441,6 +1455,10 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data)
command_event(CMD_EVENT_SAVEFILES_DEINIT, NULL);
rarch_ctl(RARCH_CTL_UNSET_INITED, NULL);
#ifdef HAVE_THREADS
async_job_free(async_jobs);
async_jobs = NULL;
#endif
break;
case RARCH_CTL_INIT:
rarch_ctl(RARCH_CTL_DEINIT, NULL);
@ -1451,6 +1469,9 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data)
settings->input.libretro_device[i] = RETRO_DEVICE_JOYPAD;
}
runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_INIT, NULL);
#ifdef HAVE_THREADS
async_jobs = async_job_new();
#endif
break;
case RARCH_CTL_SET_PATHS_REDIRECT:
if(settings->sort_savestates_enable || settings->sort_savefiles_enable)