task: api 54/180454/8
authorMichal Kolodziejski <m.kolodziejs@samsung.com>
Tue, 29 May 2018 14:07:38 +0000 (16:07 +0200)
committerLukasz Stanislawski <l.stanislaws@samsung.com>
Thu, 14 Jun 2018 13:04:26 +0000 (13:04 +0000)
Change-Id: Ia1f87d94d3b96b5a46617b375c89a811be6d9fae
Signed-off-by: Michal Kolodziejski <m.kolodziejs@samsung.com>
src/task.c [new file with mode: 0644]
src/task.h [new file with mode: 0644]

diff --git a/src/task.c b/src/task.c
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/task.h b/src/task.h
new file mode 100644 (file)
index 0000000..197e158
--- /dev/null
@@ -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