(runloop_data.c) Cleanups

This commit is contained in:
twinaphex 2015-07-09 00:01:55 +02:00
parent 51e2a128c5
commit e23499d2b2
3 changed files with 48 additions and 55 deletions

View File

@ -24,7 +24,6 @@
#include "tasks/tasks.h"
#include "input/input_overlay.h"
#ifdef HAVE_MENU
#include "menu/menu.h"
#include "menu/menu_entries.h"
@ -38,12 +37,27 @@ enum
THREAD_CODE_ALIVE
} thread_code_enum;
typedef struct data_runloop
{
bool inited;
#ifdef HAVE_THREADS
bool thread_inited;
unsigned thread_code;
bool alive;
slock_t *lock;
slock_t *cond_lock;
scond_t *cond;
sthread_t *thread;
#endif
} data_runloop_t;
static char data_runloop_msg[PATH_MAX_LENGTH];
static struct data_runloop *g_data_runloop;
data_runloop_t *rarch_main_data_get_ptr(void)
static data_runloop_t *rarch_main_data_get_ptr(void)
{
return g_data_runloop;
}
@ -122,7 +136,7 @@ static void data_runloop_iterate(bool is_thread)
}
bool rarch_main_data_active(data_runloop_t *runloop)
bool rarch_main_data_active(void)
{
bool active = false;
driver_t *driver = driver_get_ptr();
@ -174,7 +188,7 @@ static void data_thread_loop(void *data)
data_runloop_iterate(true);
if (!rarch_main_data_active(runloop))
if (!rarch_main_data_active())
rarch_sleep(10);
slock_unlock(runloop->lock);

View File

@ -17,9 +17,6 @@
#define __RETROARCH_DATA_RUNLOOP_H
#include <retro_miscellaneous.h>
#ifdef HAVE_THREADS
#include <rthreads/rthreads.h>
#endif
#ifdef __cplusplus
extern "C" {
@ -37,22 +34,6 @@ enum runloop_data_type
DATA_TYPE_DB
};
typedef struct data_runloop
{
bool inited;
#ifdef HAVE_THREADS
bool thread_inited;
unsigned thread_code;
bool alive;
slock_t *lock;
slock_t *cond_lock;
scond_t *cond;
sthread_t *thread;
#endif
} data_runloop_t;
void rarch_main_data_msg_queue_push(unsigned type,
const char *msg, const char *msg2,
unsigned prio, unsigned duration, bool flush);
@ -69,9 +50,7 @@ void rarch_main_data_init_queues(void);
void rarch_main_data_init(void);
bool rarch_main_data_active(data_runloop_t *runloop);
data_runloop_t *rarch_main_data_get_ptr(void);
bool rarch_main_data_active(void);
#ifdef __cplusplus
}

View File

@ -42,37 +42,37 @@ static CFRunLoopTimerRef iterate_timer;
/* forward declaration */
void apple_rarch_exited(void);
static void rarch_draw()
static void rarch_draw(void)
{
data_runloop_t *data_runloop = rarch_main_data_get_ptr();
runloop_t *runloop = rarch_main_get_ptr();
int ret = 0;
bool iterate = iterate_observer && !runloop->is_paused;
if (iterate)
{
runloop_t *runloop = rarch_main_get_ptr();
int ret = 0;
bool iterate = iterate_observer && !runloop->is_paused;
if (iterate)
{
ret = rarch_main_iterate();
}
rarch_main_data_iterate();
if (iterate_timer) {
if (rarch_main_data_active(data_runloop)) {
CFRunLoopAddTimer(CFRunLoopGetMain(), iterate_timer, kCFRunLoopCommonModes);
} else {
CFRunLoopRemoveTimer(CFRunLoopGetMain(), iterate_timer, kCFRunLoopCommonModes);
}
}
if (ret == -1)
{
main_exit_save_config();
main_exit(NULL);
return;
}
if (runloop->is_idle)
return;
CFRunLoopWakeUp(CFRunLoopGetMain());
}
rarch_main_data_iterate();
if (iterate_timer)
{
if (rarch_main_data_active())
CFRunLoopAddTimer(CFRunLoopGetMain(), iterate_timer, kCFRunLoopCommonModes);
else
CFRunLoopRemoveTimer(CFRunLoopGetMain(), iterate_timer, kCFRunLoopCommonModes);
}
if (ret == -1)
{
main_exit_save_config();
main_exit(NULL);
return;
}
if (runloop->is_idle)
return;
CFRunLoopWakeUp(CFRunLoopGetMain());
}
static void rarch_draw_observer(CFRunLoopObserverRef observer,