summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYossi Kantor <yossi.kantor@samsung.com>2014-03-23 15:32:06 +0200
committerDaniel Zaoui <daniel.zaoui@samsung.com>2014-03-24 08:14:31 +0200
commit5584564531b1d492199db42bfea96ae07178f79d (patch)
treee49eb7dab95b516d10c9d6dffed5e62af6ab7fd5 /src
parent260308be68254a3b13ad38246f26d7eed96f576a (diff)
Eolian: Integration of Ecore Poller
Diffstat (limited to 'src')
-rw-r--r--src/Makefile_Ecore.am10
-rw-r--r--src/lib/ecore/Ecore_Eo.h3
-rw-r--r--src/lib/ecore/Ecore_Legacy.h2
-rw-r--r--src/lib/ecore/ecore_poll.c135
-rw-r--r--src/lib/ecore/ecore_poll.eo44
5 files changed, 83 insertions, 111 deletions
diff --git a/src/Makefile_Ecore.am b/src/Makefile_Ecore.am
index df2d49a..41099e4 100644
--- a/src/Makefile_Ecore.am
+++ b/src/Makefile_Ecore.am
@@ -3,11 +3,14 @@
3 3
4BUILT_SOURCES += \ 4BUILT_SOURCES += \
5 lib/ecore/ecore_timer.eo.c \ 5 lib/ecore/ecore_timer.eo.c \
6 lib/ecore/ecore_timer.eo.h 6 lib/ecore/ecore_timer.eo.h \
7 lib/ecore/ecore_poll.eo.c \
8 lib/ecore/ecore_poll.eo.h
7 9
8ecoreeolianfilesdir = $(datadir)/eolian/include/ecore-@VMAJ@ 10ecoreeolianfilesdir = $(datadir)/eolian/include/ecore-@VMAJ@
9ecoreeolianfiles_DATA = \ 11ecoreeolianfiles_DATA = \
10 lib/ecore/ecore_timer.eo 12 lib/ecore/ecore_timer.eo \
13 lib/ecore/ecore_poll.eo
11 14
12EXTRA_DIST += \ 15EXTRA_DIST += \
13 ${ecoreeolianfiles_DATA} 16 ${ecoreeolianfiles_DATA}
@@ -23,7 +26,8 @@ lib/ecore/Ecore_Eo.h \
23lib/ecore/Ecore_Getopt.h 26lib/ecore/Ecore_Getopt.h
24 27
25nodist_installed_ecoremainheaders_DATA = \ 28nodist_installed_ecoremainheaders_DATA = \
26 lib/ecore/ecore_timer.eo.h 29 lib/ecore/ecore_timer.eo.h \
30 lib/ecore/ecore_poll.eo.h
27 31
28lib_ecore_libecore_la_SOURCES = \ 32lib_ecore_libecore_la_SOURCES = \
29lib/ecore/ecore.c \ 33lib/ecore/ecore.c \
diff --git a/src/lib/ecore/Ecore_Eo.h b/src/lib/ecore/Ecore_Eo.h
index f12121c..a1bc073 100644
--- a/src/lib/ecore/Ecore_Eo.h
+++ b/src/lib/ecore/Ecore_Eo.h
@@ -10,6 +10,8 @@ extern "C" {
10 * 10 *
11 * @{ 11 * @{
12 */ 12 */
13#include "ecore_poll.eo.h"
14#if 0
13#define ECORE_POLLER_CLASS ecore_poller_class_get() 15#define ECORE_POLLER_CLASS ecore_poller_class_get()
14const Eo_Class *ecore_poller_class_get(void) EINA_CONST; 16const Eo_Class *ecore_poller_class_get(void) EINA_CONST;
15extern EAPI Eo_Op ECORE_POLLER_BASE_ID; 17extern EAPI Eo_Op ECORE_POLLER_BASE_ID;
@@ -63,6 +65,7 @@ enum
63 */ 65 */
64#define ecore_poller_interval_get(ret) ECORE_POLLER_ID(ECORE_POLLER_SUB_ID_INTERVAL_GET), EO_TYPECHECK(int *, ret) 66#define ecore_poller_interval_get(ret) ECORE_POLLER_ID(ECORE_POLLER_SUB_ID_INTERVAL_GET), EO_TYPECHECK(int *, ret)
65 67
68#endif
66/** 69/**
67 * @} 70 * @}
68 */ 71 */
diff --git a/src/lib/ecore/Ecore_Legacy.h b/src/lib/ecore/Ecore_Legacy.h
index c7bbed7..381f0e8 100644
--- a/src/lib/ecore/Ecore_Legacy.h
+++ b/src/lib/ecore/Ecore_Legacy.h
@@ -25,7 +25,7 @@ EAPI Eina_Bool ecore_poller_poller_interval_set(Ecore_Poller *poller, int interv
25 * 25 *
26 * This returns a poller's polling interval, or 0 on error. 26 * This returns a poller's polling interval, or 0 on error.
27 */ 27 */
28EAPI int ecore_poller_poller_interval_get(Ecore_Poller *poller); 28EAPI int ecore_poller_poller_interval_get(const Ecore_Poller *poller);
29/** 29/**
30 * @brief Creates a poller to call the given function at a particular tick interval. 30 * @brief Creates a poller to call the given function at a particular tick interval.
31 * @param type The ticker type to attach the poller to. Must be ECORE_POLLER_CORE. 31 * @param type The ticker type to attach the poller to. Must be ECORE_POLLER_CORE.
diff --git a/src/lib/ecore/ecore_poll.c b/src/lib/ecore/ecore_poll.c
index f4a998f..0113136 100644
--- a/src/lib/ecore/ecore_poll.c
+++ b/src/lib/ecore/ecore_poll.c
@@ -13,13 +13,11 @@
13 13
14#define MY_CLASS_NAME "Ecore_Poller" 14#define MY_CLASS_NAME "Ecore_Poller"
15 15
16EAPI Eo_Op ECORE_POLLER_BASE_ID = EO_NOOP;
17
18#define ECORE_POLLER_CHECK(obj) \ 16#define ECORE_POLLER_CHECK(obj) \
19 if (!eo_isa((obj), ECORE_POLLER_CLASS)) \ 17 if (!eo_isa((obj), ECORE_POLLER_CLASS)) \
20 return 18 return
21 19
22struct _Ecore_Poller_Private_Data 20struct _Ecore_Poller_Data
23{ 21{
24 EINA_INLIST; 22 EINA_INLIST;
25 ECORE_MAGIC; 23 ECORE_MAGIC;
@@ -30,7 +28,7 @@ struct _Ecore_Poller_Private_Data
30 void *data; 28 void *data;
31}; 29};
32 30
33typedef struct _Ecore_Poller_Private_Data Ecore_Poller_Private_Data; 31typedef struct _Ecore_Poller_Data Ecore_Poller_Data;
34 32
35static Ecore_Timer *timer = NULL; 33static Ecore_Timer *timer = NULL;
36static int min_interval = -1; 34static int min_interval = -1;
@@ -42,7 +40,7 @@ static int poller_walking = 0;
42static double poll_interval = 0.125; 40static double poll_interval = 0.125;
43static double poll_cur_interval = 0.0; 41static double poll_cur_interval = 0.0;
44static double last_tick = 0.0; 42static double last_tick = 0.0;
45static Ecore_Poller_Private_Data *pollers[16] = 43static Ecore_Poller_Data *pollers[16] =
46{ 44{
47 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 45 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
48 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL 46 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
@@ -119,7 +117,7 @@ static Eina_Bool
119_ecore_poller_cb_timer(void *data EINA_UNUSED) 117_ecore_poller_cb_timer(void *data EINA_UNUSED)
120{ 118{
121 int i; 119 int i;
122 Ecore_Poller_Private_Data *poller, *l; 120 Ecore_Poller_Data *poller, *l;
123 int changes = 0; 121 int changes = 0;
124 122
125 at_tick++; 123 at_tick++;
@@ -170,10 +168,10 @@ _ecore_poller_cb_timer(void *data EINA_UNUSED)
170 for (l = pollers[i]; l; ) 168 for (l = pollers[i]; l; )
171 { 169 {
172 poller = l; 170 poller = l;
173 l = (Ecore_Poller_Private_Data *)EINA_INLIST_GET(l)->next; 171 l = (Ecore_Poller_Data *)EINA_INLIST_GET(l)->next;
174 if (poller->delete_me) 172 if (poller->delete_me)
175 { 173 {
176 pollers[i] = (Ecore_Poller_Private_Data *)eina_inlist_remove(EINA_INLIST_GET(pollers[i]), EINA_INLIST_GET(poller)); 174 pollers[i] = (Ecore_Poller_Data *)eina_inlist_remove(EINA_INLIST_GET(pollers[i]), EINA_INLIST_GET(poller));
177 175
178 eo_do(poller->obj, eo_parent_set(NULL)); 176 eo_do(poller->obj, eo_parent_set(NULL));
179 if (eo_destructed_is(poller->obj)) 177 if (eo_destructed_is(poller->obj))
@@ -232,8 +230,8 @@ ecore_poller_poll_interval_get(Ecore_Poller_Type type EINA_UNUSED)
232 return poll_interval; 230 return poll_interval;
233} 231}
234 232
235static void 233EOLIAN static void
236_constructor(Eo *obj, void *_pd EINA_UNUSED, va_list *list EINA_UNUSED) 234_ecore_poller_eo_base_constructor(Eo *obj, Ecore_Poller_Data *_pd EINA_UNUSED)
237{ 235{
238 eo_error_set(obj); 236 eo_error_set(obj);
239 ERR("only custom constructor can be used with '%s' class", MY_CLASS_NAME); 237 ERR("only custom constructor can be used with '%s' class", MY_CLASS_NAME);
@@ -252,17 +250,9 @@ ecore_poller_add(Ecore_Poller_Type type EINA_UNUSED,
252 return poller; 250 return poller;
253} 251}
254 252
255static void 253EOLIAN static void
256_poller_constructor(Eo *obj, void *_pd, va_list *list) 254_ecore_poller_constructor(Eo *obj, Ecore_Poller_Data *poller, Ecore_Poller_Type type EINA_UNUSED, int interval, Ecore_Task_Cb func, const void *data)
257{ 255{
258 Ecore_Poller_Type type = va_arg(*list, Ecore_Poller_Type);
259 (void)type;
260 int interval = va_arg(*list, int);
261 Ecore_Task_Cb func = va_arg(*list, Ecore_Task_Cb);
262 const void *data = va_arg(*list, const void *);
263
264
265 Ecore_Poller_Private_Data *poller = _pd;
266 poller->obj = obj; 256 poller->obj = obj;
267 257
268 int ibit; 258 int ibit;
@@ -297,36 +287,20 @@ _poller_constructor(Eo *obj, void *_pd, va_list *list)
297 poller->ibit = ibit; 287 poller->ibit = ibit;
298 poller->func = func; 288 poller->func = func;
299 poller->data = (void *)data; 289 poller->data = (void *)data;
300 pollers[poller->ibit] = (Ecore_Poller_Private_Data *)eina_inlist_prepend(EINA_INLIST_GET(pollers[poller->ibit]), EINA_INLIST_GET(poller)); 290 pollers[poller->ibit] = (Ecore_Poller_Data *)eina_inlist_prepend(EINA_INLIST_GET(pollers[poller->ibit]), EINA_INLIST_GET(poller));
301 if (poller_walking) 291 if (poller_walking)
302 just_added_poller++; 292 just_added_poller++;
303 else 293 else
304 _ecore_poller_next_tick_eval(); 294 _ecore_poller_next_tick_eval();
305} 295}
306 296
307EAPI Eina_Bool 297EOLIAN static Eina_Bool
308ecore_poller_poller_interval_set(Ecore_Poller *obj, 298_ecore_poller_interval_set(Eo *obj EINA_UNUSED, Ecore_Poller_Data *poller, int interval)
309 int interval)
310{
311 Eina_Bool ret;
312 ECORE_POLLER_CHECK(obj) EINA_FALSE;
313 eo_do(obj, ecore_poller_interval_set(interval, &ret));
314 return ret;
315}
316
317static void
318_poller_interval_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
319{ 299{
320 int interval = va_arg(*list, int);
321 Eina_Bool *ret = va_arg(*list, Eina_Bool *);
322 Eina_Bool int_ret;
323
324 EINA_MAIN_LOOP_CHECK_RETURN; 300 EINA_MAIN_LOOP_CHECK_RETURN;
325 301
326 int ibit; 302 int ibit;
327 303
328 Ecore_Poller_Private_Data *poller = _pd;
329
330 /* interval MUST be a power of 2, so enforce it */ 304 /* interval MUST be a power of 2, so enforce it */
331 if (interval < 1) interval = 1; 305 if (interval < 1) interval = 1;
332 ibit = -1; 306 ibit = -1;
@@ -338,45 +312,25 @@ _poller_interval_set(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
338 /* only allow up to 32768 - i.e. ibit == 15, so limit it */ 312 /* only allow up to 32768 - i.e. ibit == 15, so limit it */
339 if (ibit > 15) ibit = 15; 313 if (ibit > 15) ibit = 15;
340 /* if interval specified is the same as interval set, return true without wasting time */ 314 /* if interval specified is the same as interval set, return true without wasting time */
341 if (poller->ibit == ibit) 315 if (poller->ibit == ibit) return EINA_TRUE;
342 {
343 int_ret = EINA_TRUE;
344 goto end;
345 }
346 316
347 pollers[poller->ibit] = (Ecore_Poller_Private_Data *)eina_inlist_remove(EINA_INLIST_GET(pollers[poller->ibit]), EINA_INLIST_GET(poller)); 317 pollers[poller->ibit] = (Ecore_Poller_Data *)eina_inlist_remove(EINA_INLIST_GET(pollers[poller->ibit]), EINA_INLIST_GET(poller));
348 poller->ibit = ibit; 318 poller->ibit = ibit;
349 pollers[poller->ibit] = (Ecore_Poller_Private_Data *)eina_inlist_prepend(EINA_INLIST_GET(pollers[poller->ibit]), EINA_INLIST_GET(poller)); 319 pollers[poller->ibit] = (Ecore_Poller_Data *)eina_inlist_prepend(EINA_INLIST_GET(pollers[poller->ibit]), EINA_INLIST_GET(poller));
350 if (poller_walking) 320 if (poller_walking)
351 just_added_poller++; 321 just_added_poller++;
352 else 322 else
353 _ecore_poller_next_tick_eval(); 323 _ecore_poller_next_tick_eval();
354 324
355 int_ret = EINA_TRUE; 325 return EINA_TRUE;
356
357end:
358 if (ret) *ret = int_ret;
359} 326}
360 327
361EAPI int 328EOLIAN static int
362ecore_poller_poller_interval_get(Ecore_Poller *obj) 329_ecore_poller_interval_get(Eo *obj EINA_UNUSED, Ecore_Poller_Data *poller)
363{ 330{
364 int ret;
365 ECORE_POLLER_CHECK(obj) EINA_FALSE;
366 eo_do(obj, ecore_poller_interval_get(&ret));
367 return ret;
368}
369
370static void
371_poller_interval_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
372{
373 int *ret = va_arg(*list, int *);
374 *ret =0;
375
376 int ibit, interval = 1; 331 int ibit, interval = 1;
377 332
378 EINA_MAIN_LOOP_CHECK_RETURN; 333 EINA_MAIN_LOOP_CHECK_RETURN;
379 Ecore_Poller_Private_Data *poller = _pd;
380 334
381 ibit = poller->ibit; 335 ibit = poller->ibit;
382 while (ibit != 0) 336 while (ibit != 0)
@@ -384,7 +338,8 @@ _poller_interval_get(Eo *obj EINA_UNUSED, void *_pd, va_list *list)
384 ibit--; 338 ibit--;
385 interval <<= 1; 339 interval <<= 1;
386 } 340 }
387 *ret = interval; 341
342 return interval;
388} 343}
389 344
390EAPI void * 345EAPI void *
@@ -394,7 +349,7 @@ ecore_poller_del(Ecore_Poller *obj)
394 349
395 if (!obj) return NULL; 350 if (!obj) return NULL;
396 EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL); 351 EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
397 Ecore_Poller_Private_Data *poller = eo_data_scope_get(obj, MY_CLASS); 352 Ecore_Poller_Data *poller = eo_data_scope_get(obj, MY_CLASS);
398 /* we are walking the poller list - a bad idea to remove from it while 353 /* we are walking the poller list - a bad idea to remove from it while
399 * walking it, so just flag it as delete_me and come back to it after 354 * walking it, so just flag it as delete_me and come back to it after
400 * the loop has finished */ 355 * the loop has finished */
@@ -406,7 +361,7 @@ ecore_poller_del(Ecore_Poller *obj)
406 } 361 }
407 /* not in loop so safe - delete immediately */ 362 /* not in loop so safe - delete immediately */
408 data = poller->data; 363 data = poller->data;
409 pollers[poller->ibit] = (Ecore_Poller_Private_Data *)eina_inlist_remove(EINA_INLIST_GET(pollers[poller->ibit]), EINA_INLIST_GET(poller)); 364 pollers[poller->ibit] = (Ecore_Poller_Data *)eina_inlist_remove(EINA_INLIST_GET(pollers[poller->ibit]), EINA_INLIST_GET(poller));
410 365
411 eo_do(poller->obj, eo_parent_set(NULL)); 366 eo_do(poller->obj, eo_parent_set(NULL));
412 if (eo_destructed_is(poller->obj)) 367 if (eo_destructed_is(poller->obj))
@@ -418,11 +373,9 @@ ecore_poller_del(Ecore_Poller *obj)
418 return data; 373 return data;
419} 374}
420 375
421static void 376EOLIAN static void
422_destructor(Eo *obj, void *_pd, va_list *list EINA_UNUSED) 377_ecore_poller_eo_base_destructor(Eo *obj, Ecore_Poller_Data *pd)
423{ 378{
424 Ecore_Poller_Private_Data *pd = _pd;
425
426 if (!pd->delete_me) 379 if (!pd->delete_me)
427 { 380 {
428 pd->delete_me = 1; 381 pd->delete_me = 1;
@@ -440,13 +393,13 @@ void
440_ecore_poller_shutdown(void) 393_ecore_poller_shutdown(void)
441{ 394{
442 int i; 395 int i;
443 Ecore_Poller_Private_Data *poller; 396 Ecore_Poller_Data *poller;
444 397
445 for (i = 0; i < 15; i++) 398 for (i = 0; i < 15; i++)
446 { 399 {
447 while ((poller = pollers[i])) 400 while ((poller = pollers[i]))
448 { 401 {
449 pollers[i] = (Ecore_Poller_Private_Data *)eina_inlist_remove(EINA_INLIST_GET(pollers[i]), EINA_INLIST_GET(pollers[i])); 402 pollers[i] = (Ecore_Poller_Data *)eina_inlist_remove(EINA_INLIST_GET(pollers[i]), EINA_INLIST_GET(pollers[i]));
450 eo_do(poller->obj, eo_parent_set(NULL)); 403 eo_do(poller->obj, eo_parent_set(NULL));
451 if (eo_destructed_is(poller->obj)) 404 if (eo_destructed_is(poller->obj))
452 eo_manual_free(poller->obj); 405 eo_manual_free(poller->obj);
@@ -456,36 +409,4 @@ _ecore_poller_shutdown(void)
456 } 409 }
457} 410}
458 411
459static void 412#include "ecore_poll.eo.c"
460_class_constructor(Eo_Class *klass)
461{
462 const Eo_Op_Func_Description func_desc[] = {
463 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_CONSTRUCTOR), _constructor),
464 EO_OP_FUNC(EO_BASE_ID(EO_BASE_SUB_ID_DESTRUCTOR), _destructor),
465 EO_OP_FUNC(ECORE_POLLER_ID(ECORE_POLLER_SUB_ID_CONSTRUCTOR), _poller_constructor),
466 EO_OP_FUNC(ECORE_POLLER_ID(ECORE_POLLER_SUB_ID_INTERVAL_SET), _poller_interval_set),
467 EO_OP_FUNC(ECORE_POLLER_ID(ECORE_POLLER_SUB_ID_INTERVAL_GET), _poller_interval_get),
468 EO_OP_FUNC_SENTINEL
469 };
470
471 eo_class_funcs_set(klass, func_desc);
472}
473
474static const Eo_Op_Description op_desc[] = {
475 EO_OP_DESCRIPTION(ECORE_POLLER_SUB_ID_CONSTRUCTOR, "Add an idle enterer handler."),
476 EO_OP_DESCRIPTION(ECORE_POLLER_SUB_ID_INTERVAL_SET, "Changes the polling interval rate of poller."),
477 EO_OP_DESCRIPTION(ECORE_POLLER_SUB_ID_INTERVAL_GET, "Gets the polling interval rate of poller"),
478 EO_OP_DESCRIPTION_SENTINEL
479};
480static const Eo_Class_Description class_desc = {
481 EO_VERSION,
482 MY_CLASS_NAME,
483 EO_CLASS_TYPE_REGULAR,
484 EO_CLASS_DESCRIPTION_OPS(&ECORE_POLLER_BASE_ID, op_desc, ECORE_POLLER_SUB_ID_LAST),
485 NULL,
486 sizeof(Ecore_Poller_Private_Data),
487 _class_constructor,
488 NULL
489};
490
491EO_DEFINE_CLASS(ecore_poller_class_get, &class_desc, EO_BASE_CLASS, NULL)
diff --git a/src/lib/ecore/ecore_poll.eo b/src/lib/ecore/ecore_poll.eo
new file mode 100644
index 0000000..3c1de10
--- /dev/null
+++ b/src/lib/ecore/ecore_poll.eo
@@ -0,0 +1,44 @@
1class Ecore_Poller (Eo_Base)
2{
3 eo_prefix: ecore_poller;
4 constructors {
5 constructor {
6 /*@ Contructor with parameters for Ecore Poller. */
7 params {
8 @in Ecore_Poller_Type type;
9 @in int interval;
10 @in Ecore_Task_Cb func;
11 @in const void *data;
12 }
13 }
14 }
15 properties {
16 interval {
17 set {
18 /*@
19 @brief Changes the polling interval rate of @p poller.
20 @return Returns true on success, false on failure.
21
22 This allows the changing of a poller's polling interval. It is useful when
23 you want to alter a poll rate without deleting and re-creating a poller. */
24 legacy ecore_poller_poller_interval_set;
25 return Eina_Bool;
26 }
27 get {
28 /*@
29 @brief Gets the polling interval rate of @p poller.
30 @return Returns the interval, in ticks, that @p poller polls at.
31
32 This returns a poller's polling interval, or 0 on error. */
33 legacy ecore_poller_poller_interval_get;
34 }
35 values {
36 int interval; /*@ The tick interval to set; must be a power of 2 and <= 32768. */
37 }
38 }
39 }
40 implements {
41 Eo_Base::constructor;
42 Eo_Base::destructor;
43 }
44} \ No newline at end of file