(task_databse.c) Refactors

This commit is contained in:
twinaphex 2015-07-08 21:48:58 +02:00
parent 3605b97c80
commit c84ddb53fa
4 changed files with 34 additions and 4 deletions

View File

@ -298,8 +298,7 @@ void rarch_main_data_init_queues(void)
#endif
rarch_main_data_nbio_init_msg_queue();
#ifdef HAVE_LIBRETRODB
if (!runloop->db.msg_queue)
rarch_assert(runloop->db.msg_queue = msg_queue_new(8));
rarch_main_data_db_init_msg_queue();
#endif
}
@ -341,7 +340,7 @@ void rarch_main_data_msg_queue_push(unsigned type,
#endif
#ifdef HAVE_LIBRETRODB
case DATA_TYPE_DB:
queue = runloop->db.msg_queue;
queue = rarch_main_data_db_get_msg_queue_ptr();
snprintf(new_msg, sizeof(new_msg), "%s|%s", msg, msg2);
break;
#endif

View File

@ -441,4 +441,29 @@ do_poll:
runloop->db.handle->status = DATABASE_STATUS_ITERATE_BEGIN;
}
}
void *rarch_main_data_db_get_ptr(void)
{
data_runloop_t *runloop = rarch_main_data_get_ptr();
db_handle_t *db = runloop ? &runloop->db : NULL;
if (!db)
return NULL;
return db;
}
void rarch_main_data_db_init_msg_queue(void)
{
db_handle_t *db = (db_handle_t*)rarch_main_data_db_get_ptr();
if (!db->msg_queue)
rarch_assert(db->msg_queue = msg_queue_new(8));
}
msg_queue_t *rarch_main_data_db_get_msg_queue_ptr(void)
{
db_handle_t *db = (db_handle_t*)rarch_main_data_db_get_ptr();
if (!db)
return NULL;
return db->msg_queue;
}
#endif

View File

@ -69,7 +69,7 @@ typedef struct http_handle
int cb_core_updater_list(void *data_, size_t len);
int cb_core_content_list(void *data_, size_t len);
http_handle_t *http_ptr;
static http_handle_t *http_ptr;
void *rarch_main_data_http_get_ptr(void)
{

View File

@ -78,6 +78,12 @@ void rarch_main_data_nbio_image_upload_iterate(bool is_thread,
#ifdef HAVE_MENU
void rarch_main_data_db_iterate(bool is_thread, void *data);
#endif
void rarch_main_data_db_init_msg_queue(void);
void *rarch_main_data_db_get_ptr(void);
msg_queue_t *rarch_main_data_db_get_msg_queue_ptr(void);
#endif
#ifdef HAVE_OVERLAY