upload tizen1.0 source
[framework/system/sync-agent.git] / framework / include / agent-framework / Utility / fw_async_queue.h
1 /*
2  * sync-agent-framework
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: JuHak Park <juhaki.park@samsung.com>,
7  *          JuneHyuk Lee <junhyuk7.lee@samsung.com>,
8  *          SunBong Ha <sunbong.ha@samsung.com>
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */
23
24
25
26
27 /*
28  * For any sort of issue you concern as to this software,
29  * you may use following point of contact.
30  * All resources contributed on this software
31  * are orinigally written by S-Core Inc., a member of Samsung Group.
32  *
33  * JungWook Ryu <jungwook.ryu@samsung.com>
34  */
35
36 #ifndef FW_ASYNC_QUEUE_H_
37 #define FW_ASYNC_QUEUE_H_
38
39 #include <glib.h>
40
41 /**
42  * @file                fw_async_queue.h
43  * @brief       provide DataStructure - asynchronous Queue
44  */
45
46 /**
47  * @brief       determine priority
48  * @param[in]   msg1            item
49  * @param[in]   msg2            compare item
50  * @param[in]   user_data       user_data
51  * @return
52  * @see fw_async_queue_send_msg_with_compare_priority()
53  */
54 typedef int (*compare_priority_func) (const void *msg1, const void *msg2, void *user_data);
55
56 /**
57  * @brief       asynchronous Queue
58  */
59 typedef struct fw_async_queue_s fw_async_queue_t;
60 struct fw_async_queue_s {
61         GAsyncQueue *pQueue;            /**< real queue data structure */
62 };
63
64 /**
65  * @brief       create empty asynchronous Queue
66  * @return      created asynchronous queue on success, otherwise a null pointer.
67  */
68 fw_async_queue_t *fw_async_queue_alloc();
69
70 /**
71  * @brief       destroy asynchronous Queue
72  * @param[in]   pQueue          asynchronous Queue
73  */
74 void fw_async_queue_destroy(fw_async_queue_t *pQueue);
75
76 /**
77  * @brief       lock asynchronous Queue
78  * @param[in]   pQueue          asynchronous Queue
79  */
80 void fw_async_queue_lock(fw_async_queue_t *pQueue);
81
82 /**
83  * @brief       unlock asynchronous Queue
84  * @param[in]   pQueue          asynchronous Queue
85  */
86 void fw_async_queue_unlock(fw_async_queue_t *pQueue);
87
88 /**
89  * @brief       pop item from asynchronous Queue
90  * @remarks             blocking until enter item to Queue
91  * @param[in]   pQueue          asynchronous Queue
92  * return       item on success, otherwise null pointer
93  */
94 void *fw_async_queue_receive_msg(fw_async_queue_t *pQueue);
95
96 /**
97  * @brief       send item to asynchronous Queue
98  * @param[in]   pQueue          asynchronous Queue
99  * @param[in]   msg             item
100  */
101 void fw_async_queue_send_msg(fw_async_queue_t *pQueue, void *msg);
102
103 /**
104  * @brief       send item to asynchronous Queue with priority
105  * @param[in]   pQueue          asynchronous Queue
106  * @param[in]   msg             item
107  * @param[in]   cpf              priority for callback function
108  * @param[in]   user_data               user_data
109  */
110 void fw_async_queue_send_msg_with_compare_priority(fw_async_queue_t *pQueue, void *msg, compare_priority_func cpf, void *user_data);
111
112 #endif /* FW_ASYNC_QUEUE_H_ */