4462e9783808022bf6130324623966811fc1bddf
[apps/native/tizen-things-daemon.git] / daemon / include / ttd-task.h
1 /*
2  * Copyright (c) 2018 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Flora License, Version 1.1 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://floralicense.org/license/
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #ifndef __TT_DAEMON_TASK_H__
18 #define __TT_DAEMON_TASK_H__
19
20 #define TTD_TASK_PRIORITY_LOW 50
21 #define TTD_TASK_PRIORITY_NORMAL 100
22 #define TTD_TASK_PRIORITY_HIGH 150
23
24 typedef struct __ttd_task ttd_task;
25 typedef int (*ttd_task_func)(void *task_data);
26 typedef void (*ttd_task_data_free_func)(void *task_data);
27 typedef void (*ttd_task_complete_func)(int result, void *user_data);
28
29 ttd_task *ttd_task_new(int priority, ttd_task_func task_fn, void *task_data,
30         ttd_task_data_free_func data_free_fn);
31 int ttd_task_set_complete_func(ttd_task *task, ttd_task_complete_func complete_fn, void *user_data);
32 int ttd_task_run(ttd_task *task);
33 int ttd_task_sort_func(const void *a, const void *b, void *user_data);
34
35 #endif /* __TT_DAEMON_TASK_H__ */