mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 12:32:52 +00:00
Move async_job to libretro-common
This commit is contained in:
parent
c8795c8a77
commit
971f5277d7
@ -472,6 +472,7 @@ ifeq ($(HAVE_THREADS), 1)
|
|||||||
OBJ += autosave.o \
|
OBJ += autosave.o \
|
||||||
libretro-common/rthreads/rthreads.o \
|
libretro-common/rthreads/rthreads.o \
|
||||||
libretro-common/rthreads/rsemaphore.o \
|
libretro-common/rthreads/rsemaphore.o \
|
||||||
|
libretro-common/rthreads/async_job.o \
|
||||||
gfx/video_thread_wrapper.o \
|
gfx/video_thread_wrapper.o \
|
||||||
audio/audio_thread_wrapper.o
|
audio/audio_thread_wrapper.o
|
||||||
DEFINES += -DHAVE_THREADS
|
DEFINES += -DHAVE_THREADS
|
||||||
@ -869,7 +870,7 @@ ifeq ($(HAVE_NETWORKING), 1)
|
|||||||
ifeq ($(HAVE_CHEEVOS), 1)
|
ifeq ($(HAVE_CHEEVOS), 1)
|
||||||
ifeq ($(HAVE_THREADS), 1)
|
ifeq ($(HAVE_THREADS), 1)
|
||||||
DEFINES += -DHAVE_CHEEVOS
|
DEFINES += -DHAVE_CHEEVOS
|
||||||
OBJ += cheevos.o async_job.o libretro-common/utils/md5.o
|
OBJ += cheevos.o libretro-common/utils/md5.o
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
28
async_job.h
28
async_job.h
@ -1,28 +0,0 @@
|
|||||||
/* RetroArch - A frontend for libretro.
|
|
||||||
* Copyright (C) 2015 - Andre Leiradella
|
|
||||||
*
|
|
||||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
||||||
* of the GNU General Public License as published by the Free Software Found-
|
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __RARCH_ASYNC_JOB_H
|
|
||||||
#define __RARCH_ASYNC_JOB_H
|
|
||||||
|
|
||||||
typedef struct async_job async_job_t;
|
|
||||||
typedef void (*async_task_t)(void *payload);
|
|
||||||
|
|
||||||
async_job_t *async_job_new(void);
|
|
||||||
|
|
||||||
void async_job_free(async_job_t *ajob);
|
|
||||||
|
|
||||||
int async_job_add(async_job_t *ajob, async_task_t task, void *payload);
|
|
||||||
|
|
||||||
#endif /* __RARCH_ASYNC_JOB_H */
|
|
@ -24,11 +24,11 @@
|
|||||||
#include <performance.h>
|
#include <performance.h>
|
||||||
#include <runloop.h>
|
#include <runloop.h>
|
||||||
#include <retro_log.h>
|
#include <retro_log.h>
|
||||||
|
#include <rthreads/async_job.h>
|
||||||
|
|
||||||
#include "cheevos.h"
|
#include "cheevos.h"
|
||||||
#include "dynamic.h"
|
#include "dynamic.h"
|
||||||
#include "net_http_special.h"
|
#include "net_http_special.h"
|
||||||
#include "async_job.h"
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -90,7 +90,6 @@ ACHIEVEMENTS
|
|||||||
#include "../libretro-common/formats/json/jsonsax.c"
|
#include "../libretro-common/formats/json/jsonsax.c"
|
||||||
#include "../libretro-common/utils/md5.c"
|
#include "../libretro-common/utils/md5.c"
|
||||||
#include "../net_http_special.c"
|
#include "../net_http_special.c"
|
||||||
#include "../async_job.c"
|
|
||||||
#include "../cheevos.c"
|
#include "../cheevos.c"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -733,6 +732,7 @@ THREAD
|
|||||||
#elif defined(HAVE_THREADS)
|
#elif defined(HAVE_THREADS)
|
||||||
#include "../libretro-common/rthreads/rthreads.c"
|
#include "../libretro-common/rthreads/rthreads.c"
|
||||||
#include "../libretro-common/rthreads/rsemaphore.c"
|
#include "../libretro-common/rthreads/rsemaphore.c"
|
||||||
|
#include "../libretro-common/rthreads/async_job.c"
|
||||||
#include "../gfx/video_thread_wrapper.c"
|
#include "../gfx/video_thread_wrapper.c"
|
||||||
#include "../audio/audio_thread_wrapper.c"
|
#include "../audio/audio_thread_wrapper.c"
|
||||||
#include "../autosave.c"
|
#include "../autosave.c"
|
||||||
|
35
libretro-common/include/rthreads/async_job.h
Normal file
35
libretro-common/include/rthreads/async_job.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
|
*
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
* The following license statement only applies to this file (async_job.h).
|
||||||
|
* ---------------------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge,
|
||||||
|
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __LIBRETRO_SDK_ASYNC_JOB_H
|
||||||
|
#define __LIBRETRO_SDK_ASYNC_JOB_H
|
||||||
|
|
||||||
|
typedef struct async_job async_job_t;
|
||||||
|
typedef void (*async_task_t)(void *payload);
|
||||||
|
|
||||||
|
async_job_t *async_job_new(void);
|
||||||
|
|
||||||
|
void async_job_free(async_job_t *ajob);
|
||||||
|
|
||||||
|
int async_job_add(async_job_t *ajob, async_task_t task, void *payload);
|
||||||
|
|
||||||
|
#endif /* __LIBRETRO_SDK_ASYNC_JOB_H */
|
@ -1,16 +1,23 @@
|
|||||||
/* RetroArch - A frontend for libretro.
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
* Copyright (C) 2015 - Andre Leiradella
|
|
||||||
*
|
*
|
||||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
* ---------------------------------------------------------------------------------------
|
||||||
* of the GNU General Public License as published by the Free Software Found-
|
* The following license statement only applies to this file (rsemaphore.h).
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* Permission is hereby granted, free of charge,
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||||
* PURPOSE. See the GNU General Public License for more details.
|
* to deal in the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LIBRETRO_SDK_SEMAPHORE_H
|
#ifndef __LIBRETRO_SDK_SEMAPHORE_H
|
||||||
@ -34,4 +41,4 @@ void ssem_wait(ssem_t *semaphore);
|
|||||||
|
|
||||||
void ssem_signal(ssem_t *semaphore);
|
void ssem_signal(ssem_t *semaphore);
|
||||||
|
|
||||||
#endif /* __RARCH_SEMAPHORE_H */
|
#endif /* __LIBRETRO_SDK_SEMAPHORE_H */
|
||||||
|
@ -1,23 +1,30 @@
|
|||||||
/* RetroArch - A frontend for libretro.
|
/* Copyright (C) 2010-2015 The RetroArch team
|
||||||
* Copyright (C) 2015 - Andre Leiradella
|
|
||||||
*
|
*
|
||||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
* ---------------------------------------------------------------------------------------
|
||||||
* of the GNU General Public License as published by the Free Software Found-
|
* The following license statement only applies to this file (async_job.c).
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
* ---------------------------------------------------------------------------------------
|
||||||
*
|
*
|
||||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
* Permission is hereby granted, free of charge,
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
|
||||||
* PURPOSE. See the GNU General Public License for more details.
|
* to deal in the Software without restriction, including without limitation the rights to
|
||||||
|
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <rthreads/rthreads.h>
|
#include <rthreads/rthreads.h>
|
||||||
#include <rthreads/rsemaphore.h>
|
#include <rthreads/rsemaphore.h>
|
||||||
#include <async_job.h>
|
#include <rthreads/async_job.h>
|
||||||
|
|
||||||
typedef struct async_job_node async_job_node_t;
|
typedef struct async_job_node async_job_node_t;
|
||||||
|
|
||||||
@ -40,8 +47,8 @@ struct async_job
|
|||||||
|
|
||||||
static void async_job_processor(void *userdata)
|
static void async_job_processor(void *userdata)
|
||||||
{
|
{
|
||||||
async_job_t *ajob = (async_job_t*)userdata;
|
|
||||||
async_job_node_t *node;
|
async_job_node_t *node;
|
||||||
|
async_job_t *ajob = (async_job_t*)userdata;
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
@ -64,14 +71,11 @@ static void async_job_processor(void *userdata)
|
|||||||
|
|
||||||
async_job_t *async_job_new(void)
|
async_job_t *async_job_new(void)
|
||||||
{
|
{
|
||||||
async_job_t *ajob = (async_job_t*)malloc(sizeof(*ajob));
|
async_job_t *ajob = (async_job_t*)calloc(1, sizeof(*ajob));
|
||||||
|
|
||||||
if (ajob)
|
if (ajob)
|
||||||
{
|
{
|
||||||
ajob->first = NULL;
|
ajob->lock = slock_new();
|
||||||
ajob->last = NULL;
|
|
||||||
ajob->finish = 0;
|
|
||||||
ajob->lock = slock_new();
|
|
||||||
|
|
||||||
if (ajob->lock)
|
if (ajob->lock)
|
||||||
{
|
{
|
||||||
@ -107,14 +111,13 @@ void async_job_free(async_job_t *ajob)
|
|||||||
|
|
||||||
int async_job_add(async_job_t *ajob, async_task_t task, void *payload)
|
int async_job_add(async_job_t *ajob, async_task_t task, void *payload)
|
||||||
{
|
{
|
||||||
async_job_node_t *node = (async_job_node_t*)malloc(sizeof(*node));
|
async_job_node_t *node = (async_job_node_t*)calloc(1, sizeof(*node));
|
||||||
|
|
||||||
if (!node)
|
if (!node)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
node->task = task;
|
node->task = task;
|
||||||
node->payload = payload;
|
node->payload = payload;
|
||||||
node->next = NULL;
|
|
||||||
|
|
||||||
slock_lock(ajob->lock);
|
slock_lock(ajob->lock);
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user