summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Kolodziejski <m.kolodziejs@samsung.com>2018-05-29 16:07:38 +0200
committerLukasz Stanislawski <l.stanislaws@samsung.com>2018-06-14 13:04:26 +0000
commita2b192b391a7dea4e5835ccbbab2f56e25d989c9 (patch)
tree91200e91c977d3ffb49c592a655ff9f75358986d
parentefa20431292aaa7bfcb0b0cce7a444cd4a130481 (diff)
downloadttsd-worker-task-a2b192b391a7dea4e5835ccbbab2f56e25d989c9.tar.gz
ttsd-worker-task-a2b192b391a7dea4e5835ccbbab2f56e25d989c9.tar.bz2
ttsd-worker-task-a2b192b391a7dea4e5835ccbbab2f56e25d989c9.zip
task: api
Change-Id: Ia1f87d94d3b96b5a46617b375c89a811be6d9fae Signed-off-by: Michal Kolodziejski <m.kolodziejs@samsung.com>
-rw-r--r--src/task.c0
-rw-r--r--src/task.h84
2 files changed, 84 insertions, 0 deletions
diff --git a/src/task.c b/src/task.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/task.c
diff --git a/src/task.h b/src/task.h
new file mode 100644
index 0000000..197e158
--- /dev/null
+++ b/src/task.h
@@ -0,0 +1,84 @@
+/*
+* Copyright 2018 Samsung Electronics Co., Ltd
+*
+* Licensed under the Flora License, Version 1.1 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://floralicense.org/license/
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+/**
+ * @brief Called on the task execution.
+ */
+typedef void(*task_execute_cb)(task_t *task);
+
+/**
+ * @brief Called on the task initialization.
+ */
+typedef int(*task_init_cb)(task_t *task);
+
+/**
+ * @brief Called on the task shutdown.
+ */
+typedef void(*task_shutdown_cb)(task_t *task);
+
+/**
+ * @brief List of possible task frequencies.
+ */
+typedef enum task_frequency {
+ FREQUENCY_LOW,
+ FREQUENCY_MEDIUM,
+ FREQUENCY_HIGH,
+ FREQUENCY_NO_WAIT
+} task_frequency_e;
+
+/**
+ * @brief The task template.
+ */
+typedef struct task
+{
+ task_init_cb init;
+ task_shutdown_cb shutdown;
+ task_execute_cb execute;
+ task_frequency_e frequency;
+ void *user_data;
+} task_t;
+
+/**
+ * @brief Initializes the task.
+ * @param[in] task The task handle.
+ */
+int task_initialize(task_t *task);
+
+/**
+ * @brief Shutdowns the task.
+ * @param[in] task The task handle.
+ */
+void task_shutdown(task_t *task);
+
+/**
+ * @brief Executes the task.
+ * @param[in] task The task handle.
+ */
+void task_execute(task_t *task);
+
+/**
+ * @brief Sets the user data.
+ * @param[in] task The task handle.
+ * @param[in] data The user data.
+ */
+void task_set_user_data(task_t *task, void *data);
+
+/**
+ * @brief Gets the user data.
+ * @param[in] task The task handle.
+ * @return User data associated with given task.
+ */
+void *task_get_user_data(task_t *task); \ No newline at end of file