summaryrefslogtreecommitdiff
path: root/src/lib/ecore/ecore_idle_enterer.c
diff options
context:
space:
mode:
authorYossi Kantor <yossi.kantor@samsung.com>2014-03-24 10:09:18 +0200
committerDaniel Zaoui <daniel.zaoui@samsung.com>2014-04-02 10:05:37 +0300
commit353612388672805346dbbe473180808ded94ae47 (patch)
tree3ed5df083615ff00d293126db8c7e383b68968ac /src/lib/ecore/ecore_idle_enterer.c
parent277c3e2ef38606678b6c52ed1841ab1b74c962bc (diff)
Eolian: Integration of Ecore Idle Enterer
Diffstat (limited to 'src/lib/ecore/ecore_idle_enterer.c')
-rw-r--r--src/lib/ecore/ecore_idle_enterer.c95
1 files changed, 26 insertions, 69 deletions
diff --git a/src/lib/ecore/ecore_idle_enterer.c b/src/lib/ecore/ecore_idle_enterer.c
index bf8d48e..102f5bb 100644
--- a/src/lib/ecore/ecore_idle_enterer.c
+++ b/src/lib/ecore/ecore_idle_enterer.c
@@ -13,9 +13,7 @@
13 13
14#define MY_CLASS_NAME "Ecore_Idle_Enterer" 14#define MY_CLASS_NAME "Ecore_Idle_Enterer"
15 15
16EAPI Eo_Op ECORE_IDLE_ENTERER_BASE_ID = EO_NOOP; 16struct _Ecore_Idle_Enterer_Data
17
18struct _Ecore_Idle_Enterer_Private_Data
19{ 17{
20 EINA_INLIST; 18 EINA_INLIST;
21 Ecore_Idle_Enterer *obj; 19 Ecore_Idle_Enterer *obj;
@@ -24,10 +22,10 @@ struct _Ecore_Idle_Enterer_Private_Data
24 int references; 22 int references;
25 Eina_Bool delete_me : 1; 23 Eina_Bool delete_me : 1;
26}; 24};
27typedef struct _Ecore_Idle_Enterer_Private_Data Ecore_Idle_Enterer_Private_Data; 25typedef struct _Ecore_Idle_Enterer_Data Ecore_Idle_Enterer_Data;
28 26
29static Ecore_Idle_Enterer_Private_Data *idle_enterers = NULL; 27static Ecore_Idle_Enterer_Data *idle_enterers = NULL;
30static Ecore_Idle_Enterer_Private_Data *idle_enterer_current = NULL; 28static Ecore_Idle_Enterer_Data *idle_enterer_current = NULL;
31static int idle_enterers_delete_me = 0; 29static int idle_enterers_delete_me = 0;
32 30
33static void * 31static void *
@@ -41,7 +39,7 @@ _ecore_idle_enterer_del(Ecore_Idle_Enterer *idle_enterer);
41 39
42static Eina_Bool 40static Eina_Bool
43_ecore_idle_enterer_add(Ecore_Idle_Enterer *obj, 41_ecore_idle_enterer_add(Ecore_Idle_Enterer *obj,
44 Ecore_Idle_Enterer_Private_Data *ie, 42 Ecore_Idle_Enterer_Data *ie,
45 Ecore_Task_Cb func, 43 Ecore_Task_Cb func,
46 const void *data) 44 const void *data)
47{ 45{
@@ -87,17 +85,13 @@ ecore_idle_enterer_add(Ecore_Task_Cb func,
87 return ie; 85 return ie;
88} 86}
89 87
90static void 88EOLIAN static void
91_idle_enterer_after_constructor(Eo *obj, void *_pd, va_list *list) 89_ecore_idle_enterer_after_constructor(Eo *obj, Ecore_Idle_Enterer_Data *ie, Ecore_Task_Cb func, const void *data)
92{ 90{
93 Ecore_Task_Cb func = va_arg(*list, Ecore_Task_Cb);
94 const void *data = va_arg(*list, const void *);
95
96 _ecore_lock(); 91 _ecore_lock();
97 Ecore_Idle_Enterer_Private_Data *ie = _pd;
98 if (!_ecore_idle_enterer_add(obj, ie, func, data)) goto unlock; 92 if (!_ecore_idle_enterer_add(obj, ie, func, data)) goto unlock;
99 93
100 idle_enterers = (Ecore_Idle_Enterer_Private_Data *)eina_inlist_append(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(ie)); 94 idle_enterers = (Ecore_Idle_Enterer_Data *)eina_inlist_append(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(ie));
101 95
102unlock: 96unlock:
103 _ecore_unlock(); 97 _ecore_unlock();
@@ -123,24 +117,20 @@ ecore_idle_enterer_before_add(Ecore_Task_Cb func,
123 return ie; 117 return ie;
124} 118}
125 119
126static void 120EOLIAN static void
127_idle_enterer_before_constructor(Eo *obj, void *_pd, va_list *list) 121_ecore_idle_enterer_before_constructor(Eo *obj, Ecore_Idle_Enterer_Data *ie, Ecore_Task_Cb func, const void *data)
128{ 122{
129 Ecore_Task_Cb func = va_arg(*list, Ecore_Task_Cb);
130 const void *data = va_arg(*list, const void *);
131
132 _ecore_lock(); 123 _ecore_lock();
133 Ecore_Idle_Enterer_Private_Data *ie = _pd;
134 if (!_ecore_idle_enterer_add(obj, ie, func, data)) goto unlock; 124 if (!_ecore_idle_enterer_add(obj, ie, func, data)) goto unlock;
135 125
136 idle_enterers = (Ecore_Idle_Enterer_Private_Data *)eina_inlist_prepend(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(ie)); 126 idle_enterers = (Ecore_Idle_Enterer_Data *)eina_inlist_prepend(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(ie));
137 127
138unlock: 128unlock:
139 _ecore_unlock(); 129 _ecore_unlock();
140} 130}
141 131
142static void 132EOLIAN static void
143_constructor(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED) 133_ecore_idle_enterer_eo_base_constructor(Eo *obj, Ecore_Idle_Enterer_Data *_pd EINA_UNUSED)
144{ 134{
145 eo_error_set(obj); 135 eo_error_set(obj);
146 ERR("only custom constructor can be used with '%s' class", MY_CLASS_NAME); 136 ERR("only custom constructor can be used with '%s' class", MY_CLASS_NAME);
@@ -174,7 +164,7 @@ ecore_idle_enterer_del(Ecore_Idle_Enterer *idle_enterer)
174static void * 164static void *
175_ecore_idle_enterer_del(Ecore_Idle_Enterer *obj) 165_ecore_idle_enterer_del(Ecore_Idle_Enterer *obj)
176{ 166{
177 Ecore_Idle_Enterer_Private_Data *idle_enterer = eo_data_scope_get(obj, MY_CLASS); 167 Ecore_Idle_Enterer_Data *idle_enterer = eo_data_scope_get(obj, MY_CLASS);
178 168
179 if (!idle_enterer) return NULL; 169 if (!idle_enterer) return NULL;
180 EINA_SAFETY_ON_TRUE_RETURN_VAL(idle_enterer->delete_me, NULL); 170 EINA_SAFETY_ON_TRUE_RETURN_VAL(idle_enterer->delete_me, NULL);
@@ -183,11 +173,9 @@ _ecore_idle_enterer_del(Ecore_Idle_Enterer *obj)
183 return idle_enterer->data; 173 return idle_enterer->data;
184} 174}
185 175
186static void 176EOLIAN static void
187_destructor(Eo *obj, void *_pd, va_list *list EINA_UNUSED) 177_ecore_idle_enterer_eo_base_destructor(Eo *obj, Ecore_Idle_Enterer_Data *idle_enterer)
188{ 178{
189 Ecore_Idle_Enterer_Private_Data *idle_enterer = _pd;
190
191 idle_enterer->delete_me = 1; 179 idle_enterer->delete_me = 1;
192 idle_enterers_delete_me = 1; 180 idle_enterers_delete_me = 1;
193 181
@@ -197,10 +185,10 @@ _destructor(Eo *obj, void *_pd, va_list *list EINA_UNUSED)
197void 185void
198_ecore_idle_enterer_shutdown(void) 186_ecore_idle_enterer_shutdown(void)
199{ 187{
200 Ecore_Idle_Enterer_Private_Data *ie; 188 Ecore_Idle_Enterer_Data *ie;
201 while ((ie = idle_enterers)) 189 while ((ie = idle_enterers))
202 { 190 {
203 idle_enterers = (Ecore_Idle_Enterer_Private_Data *)eina_inlist_remove(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(idle_enterers)); 191 idle_enterers = (Ecore_Idle_Enterer_Data *)eina_inlist_remove(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(idle_enterers));
204 192
205 eo_do(ie->obj, eo_parent_set(NULL)); 193 eo_do(ie->obj, eo_parent_set(NULL));
206 if (eo_destructed_is(ie->obj)) 194 if (eo_destructed_is(ie->obj))
@@ -224,12 +212,12 @@ _ecore_idle_enterer_call(void)
224 { 212 {
225 /* recursive main loop, continue from where we were */ 213 /* recursive main loop, continue from where we were */
226 idle_enterer_current = 214 idle_enterer_current =
227 (Ecore_Idle_Enterer_Private_Data *)EINA_INLIST_GET(idle_enterer_current)->next; 215 (Ecore_Idle_Enterer_Data *)EINA_INLIST_GET(idle_enterer_current)->next;
228 } 216 }
229 217
230 while (idle_enterer_current) 218 while (idle_enterer_current)
231 { 219 {
232 Ecore_Idle_Enterer_Private_Data *ie = (Ecore_Idle_Enterer_Private_Data *)idle_enterer_current; 220 Ecore_Idle_Enterer_Data *ie = (Ecore_Idle_Enterer_Data *)idle_enterer_current;
233 if (!ie->delete_me) 221 if (!ie->delete_me)
234 { 222 {
235 ie->references++; 223 ie->references++;
@@ -241,17 +229,17 @@ _ecore_idle_enterer_call(void)
241 } 229 }
242 if (idle_enterer_current) /* may have changed in recursive main loops */ 230 if (idle_enterer_current) /* may have changed in recursive main loops */
243 idle_enterer_current = 231 idle_enterer_current =
244 (Ecore_Idle_Enterer_Private_Data *)EINA_INLIST_GET(idle_enterer_current)->next; 232 (Ecore_Idle_Enterer_Data *)EINA_INLIST_GET(idle_enterer_current)->next;
245 } 233 }
246 if (idle_enterers_delete_me) 234 if (idle_enterers_delete_me)
247 { 235 {
248 Ecore_Idle_Enterer_Private_Data *l; 236 Ecore_Idle_Enterer_Data *l;
249 int deleted_idler_enterers_in_use = 0; 237 int deleted_idler_enterers_in_use = 0;
250 238
251 for (l = idle_enterers; l; ) 239 for (l = idle_enterers; l; )
252 { 240 {
253 Ecore_Idle_Enterer_Private_Data *ie = l; 241 Ecore_Idle_Enterer_Data *ie = l;
254 l = (Ecore_Idle_Enterer_Private_Data *)EINA_INLIST_GET(l)->next; 242 l = (Ecore_Idle_Enterer_Data *)EINA_INLIST_GET(l)->next;
255 if (ie->delete_me) 243 if (ie->delete_me)
256 { 244 {
257 if (ie->references) 245 if (ie->references)
@@ -260,7 +248,7 @@ _ecore_idle_enterer_call(void)
260 continue; 248 continue;
261 } 249 }
262 250
263 idle_enterers = (Ecore_Idle_Enterer_Private_Data *)eina_inlist_remove(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(ie)); 251 idle_enterers = (Ecore_Idle_Enterer_Data *)eina_inlist_remove(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(ie));
264 252
265 eo_do(ie->obj, eo_parent_set(NULL)); 253 eo_do(ie->obj, eo_parent_set(NULL));
266 if (eo_destructed_is(ie->obj)) 254 if (eo_destructed_is(ie->obj))
@@ -281,35 +269,4 @@ _ecore_idle_enterer_exist(void)
281 return 0; 269 return 0;
282} 270}
283 271
284static void 272#include "ecore_idle_enterer.eo.c" \ No newline at end of file
285_class_constructor(Eo_Class *klass)
286{
287 const Eo_Op_Func_Description func_desc[] = {
288 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
289 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
290
291 EO_OP_FUNC(ECORE_IDLE_ENTERER_ID(ECORE_IDLE_ENTERER_SUB_ID_AFTER_CONSTRUCTOR), _idle_enterer_after_constructor),
292 EO_OP_FUNC(ECORE_IDLE_ENTERER_ID(ECORE_IDLE_ENTERER_SUB_ID_BEFORE_CONSTRUCTOR), _idle_enterer_before_constructor),
293 EO_OP_FUNC_SENTINEL
294 };
295
296 eo_class_funcs_set(klass, func_desc);
297}
298
299static const Eo_Op_Description op_desc[] = {
300 EO_OP_DESCRIPTION(ECORE_IDLE_ENTERER_SUB_ID_AFTER_CONSTRUCTOR, "Add an idle enterer handler."),
301 EO_OP_DESCRIPTION(ECORE_IDLE_ENTERER_SUB_ID_BEFORE_CONSTRUCTOR, "Add an idle enterer handler at the start of the list so it gets called earlier than others."),
302 EO_OP_DESCRIPTION_SENTINEL
303};
304static const Eo_Class_Description class_desc = {
305 EO_VERSION,
306 MY_CLASS_NAME,
307 EO_CLASS_TYPE_REGULAR,
308 EO_CLASS_DESCRIPTION_OPS(&ECORE_IDLE_ENTERER_BASE_ID, op_desc, ECORE_IDLE_ENTERER_SUB_ID_LAST),
309 NULL,
310 sizeof(Ecore_Idle_Enterer_Private_Data),
311 _class_constructor,
312 NULL
313};
314
315EO_DEFINE_CLASS(ecore_idle_enterer_class_get, &class_desc, EO_BASE_CLASS, NULL)