From 0764b65dc40164f88ecd10a0b5d8f781ca4f3193 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 28 Jan 2016 09:38:21 +0100 Subject: [PATCH] Add more TASK_CTL commands --- tasks/tasks.c | 16 ++++++---------- tasks/tasks.h | 31 +++++++++++++------------------ 2 files changed, 19 insertions(+), 28 deletions(-) diff --git a/tasks/tasks.c b/tasks/tasks.c index 54dccf493c..7919f71fe4 100644 --- a/tasks/tasks.c +++ b/tasks/tasks.c @@ -414,16 +414,6 @@ void rarch_task_push(rarch_task_t *task) impl_current->push_running(task); } -void rarch_task_wait(void) -{ - impl_current->wait(); -} - -void rarch_task_reset(void) -{ - impl_current->reset(); -} - bool rarch_task_find(rarch_task_finder_t func, void *user_data) { return impl_current->find(func, user_data); @@ -433,6 +423,12 @@ bool task_ctl(enum task_ctl_state state, void *data) { switch (state) { + case TASK_CTL_RESET: + impl_current->reset(); + break; + case TASK_CTL_WAIT: + impl_current->wait(); + break; case TASK_CTL_NONE: default: break; diff --git a/tasks/tasks.h b/tasks/tasks.h index d0da4f1554..c0722eb3ee 100644 --- a/tasks/tasks.h +++ b/tasks/tasks.h @@ -27,7 +27,19 @@ extern "C" { enum task_ctl_state { - TASK_CTL_NONE = 0 + TASK_CTL_NONE = 0, + + /* Blocks until all tasks have finished. + * This must only be called from the main thread. */ + TASK_CTL_WAIT, + + /* Sends a signal to terminate all the tasks. + * + * This won't terminate the tasks immediately. + * They will finish as soon as possible. + * + * This must only be called from the main thread. */ + TASK_CTL_RESET, }; typedef struct rarch_task rarch_task_t; @@ -98,23 +110,6 @@ void rarch_task_deinit(void); */ void rarch_task_check(void); -/** - * @brief Sends a signal to terminate all the tasks. - * - * This function won't terminate the tasks immediately. They will finish as - * soon as possible. - * - * This function must only be called from the main thread. - */ -void rarch_task_reset(void); - -/** - * @brief Blocks until all tasks have finished. - * - * This function must only be called from the main thread. - */ -void rarch_task_wait(void); - /** * @brief Calls func for every running task until it returns true. *