From b807b898377ab3932147dbb9201140242ce1f6b7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 28 Jan 2016 09:42:55 +0100 Subject: [PATCH] Add TASK_CTL_PUSH --- tasks/task_database.c | 2 +- tasks/task_decompress.c | 2 +- tasks/task_file_transfer.c | 2 +- tasks/task_http.c | 2 +- tasks/task_overlay.c | 2 +- tasks/tasks.c | 15 ++++++++------- tasks/tasks.h | 13 ++++--------- 7 files changed, 17 insertions(+), 21 deletions(-) diff --git a/tasks/task_database.c b/tasks/task_database.c index a7a6431a9b..17554acd27 100644 --- a/tasks/task_database.c +++ b/tasks/task_database.c @@ -581,7 +581,7 @@ bool rarch_task_push_dbscan(const char *fullpath, bool directory, rarch_task_cal if (db->handle) db->handle->status = DATABASE_STATUS_ITERATE_BEGIN; - rarch_task_push(t); + task_ctl(TASK_CTL_PUSH, t); return true; diff --git a/tasks/task_decompress.c b/tasks/task_decompress.c index b071d4a02e..6482c7dda1 100644 --- a/tasks/task_decompress.c +++ b/tasks/task_decompress.c @@ -294,7 +294,7 @@ bool rarch_task_push_decompress( snprintf(tmp, sizeof(tmp), "%s '%s'", msg_hash_to_str(MSG_EXTRACTING), path_basename(source_file)); t->title = strdup(tmp); - rarch_task_push(t); + task_ctl(TASK_CTL_PUSH, t); return true; diff --git a/tasks/task_file_transfer.c b/tasks/task_file_transfer.c index 01d27be5f7..c5b48c1111 100644 --- a/tasks/task_file_transfer.c +++ b/tasks/task_file_transfer.c @@ -360,7 +360,7 @@ bool rarch_task_push_image_load(const char *fullpath, const char *type, rarch_ta t->callback = cb; t->user_data = user_data; - rarch_task_push(t); + task_ctl(TASK_CTL_PUSH, t); #endif return true; } diff --git a/tasks/task_http.c b/tasks/task_http.c index 6bde2b11f0..724acf59e0 100644 --- a/tasks/task_http.c +++ b/tasks/task_http.c @@ -252,7 +252,7 @@ bool rarch_task_push_http_transfer(const char *url, const char *type, rarch_task snprintf(tmp, sizeof(tmp), "%s '%s'", msg_hash_to_str(MSG_DOWNLOADING), path_basename(url)); t->title = strdup(tmp); - rarch_task_push(t); + task_ctl(TASK_CTL_PUSH, t); return true; diff --git a/tasks/task_overlay.c b/tasks/task_overlay.c index cb8bca7758..c6775b8d24 100644 --- a/tasks/task_overlay.c +++ b/tasks/task_overlay.c @@ -714,7 +714,7 @@ static bool rarch_task_push_overlay_load(const char *overlay_path, t->callback = cb; t->user_data = user_data; - rarch_task_push(t); + task_ctl(TASK_CTL_PUSH, t); return true; error: diff --git a/tasks/tasks.c b/tasks/tasks.c index 7919f71fe4..ee132cad03 100644 --- a/tasks/tasks.c +++ b/tasks/tasks.c @@ -407,13 +407,6 @@ void rarch_task_check(void) impl_current->gather(); } -/* The lack of NULL checks in the following functions is proposital - * to ensure correct control flow by the users. */ -void rarch_task_push(rarch_task_t *task) -{ - impl_current->push_running(task); -} - bool rarch_task_find(rarch_task_finder_t func, void *user_data) { return impl_current->find(func, user_data); @@ -423,6 +416,14 @@ bool task_ctl(enum task_ctl_state state, void *data) { switch (state) { + case TASK_CTL_PUSH: + { + /* The lack of NULL checks in the following functions is proposital + * to ensure correct control flow by the users. */ + rarch_task_t *task = (rarch_task_t*)data; + impl_current->push_running(task); + break; + } case TASK_CTL_RESET: impl_current->reset(); break; diff --git a/tasks/tasks.h b/tasks/tasks.h index c0722eb3ee..edaa9f2b8a 100644 --- a/tasks/tasks.h +++ b/tasks/tasks.h @@ -33,6 +33,10 @@ enum task_ctl_state * This must only be called from the main thread. */ TASK_CTL_WAIT, + /* Pushes a task + * The task will start as soon as possible. */ + TASK_CTL_PUSH, + /* Sends a signal to terminate all the tasks. * * This won't terminate the tasks immediately. @@ -119,15 +123,6 @@ void rarch_task_check(void); */ bool rarch_task_find(rarch_task_finder_t func, void *user_data); -/** - * @brief Pushes a task - * - * The task will start as soon as possible. - * - * @param task - */ -void rarch_task_push(rarch_task_t *task); - #ifdef HAVE_NETWORKING typedef struct { char *data;