Tizen 2.1 base
[platform/core/system/sync-agent.git] / src / framework / engine-controller / task_pool.h
1 /*
2  * sync-agent
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Apache License, Version 2.0 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #ifndef TASK_POOL_H_
19 #define TASK_POOL_H_
20
21 #include <glib.h>
22 #include <stdbool.h>
23 #include "engine-controller/task.h"
24
25 /**
26  * @file                task_pool.h
27  * @brief       Defines engine controller task pool APIs
28  */
29
30 /** @addtogroup engine_controller
31  *      @{
32  */
33
34 /**
35  * @brief Structure for task pool
36  */
37 typedef struct ec_task_pool_s ec_task_pool_t;
38
39 /**
40  * @brief Structure for task pool
41  * @remarks it contains only root task
42  */
43 struct ec_task_pool_s {
44         GHashTable *task_hash;  /**< key : sync_agent_ec_uint (request_id)
45                                    value : ec_task_t* */
46 };
47
48 /**
49  * @brief Create task pool
50  * @return ec_task_pool_t on success, NULL on fail
51  * @retval ec_task_pool_t Successful
52  * @retval NULL Fail
53  */
54 ec_task_pool_t *ec_task_pool_create_task_pool();
55
56 /**
57  * @brief Free task pool
58  * @param[in] task_pool ec_task_pool_t
59  */
60 void ec_task_pool_free_task_pool(ec_task_pool_t * task_pool);
61
62 /**
63  * @brief Add task
64  * @param[in] task_pool ec_task_pool_t
65  * @param[in] request_id request id
66  * @param[in] task ec_task_t
67  */
68 void ec_task_pool_add_task(ec_task_pool_t * task_pool, sync_agent_ec_uint request_id, ec_task_t * task);
69
70 /**
71  * @brief Fetch task
72  * @param[in] task_pool ec_task_pool_t
73  * @param[in] request_id request id
74  * @return ec_task_t on success, NULL on fail
75  * @retval ec_task_t Successful
76  * @retval NULL Fail
77  */
78 ec_task_t *ec_task_pool_fetch_task(ec_task_pool_t * task_pool, sync_agent_ec_uint request_id);
79
80 /**
81  * @brief Fetch all tasks
82  * @param[in] task_pool ec_task_pool_t
83  * @return ec_task_t list on success, NULL on fail
84  * @retval ec_task_t list Successful
85  * @retval NULL Fail
86  */
87 GList *ec_task_pool_fetch_all_tasks(ec_task_pool_t * task_pool);
88
89 /**
90  * @brief remove task
91  * @param[in] task_pool ec_task_pool_t
92  * @param[in] request_id request id
93  */
94 void ec_task_pool_remove_task(ec_task_pool_t * task_pool, sync_agent_ec_uint request_id);
95
96 /**
97  *      @}
98  */
99
100 #endif                          /* TASK_POOL_H_ */