Initialize Tizen 2.3
[framework/uifw/ecore.git] / mobile / src / examples / ecore_poller_example.c
1 #include <Ecore.h>
2 #include <unistd.h>
3
4 static double _initial_time = 0;
5
6 static Eina_Bool
7 _poller_print_cb(void *data)
8 {
9    char *str = data;
10    printf("Ecore Poller '%s' callback called after %0.3f seconds.\n",
11           str, ecore_time_get() - _initial_time);
12
13    return ECORE_CALLBACK_RENEW;
14 }
15
16 int
17 main(int argc, char **argv)
18 {
19    double interval = 0.3; // tick each 0.3 seconds
20    Ecore_Poller *poller1, *poller2;
21    char *str1 = "poller1";
22    char *str2 = "poller2";
23
24    if (!ecore_init())
25      {
26         printf("ERROR: Cannot init Ecore!\n");
27         return -1;
28      }
29
30    _initial_time = ecore_time_get();
31
32    ecore_poller_poll_interval_set(ECORE_POLLER_CORE, interval);
33
34    poller1 = ecore_poller_add(ECORE_POLLER_CORE, 4, _poller_print_cb, str1);
35    poller2 = ecore_poller_add(ECORE_POLLER_CORE, 8, _poller_print_cb, str2);
36
37    ecore_main_loop_begin();
38
39    printf("changing poller2 interval to 16\n");
40
41    ecore_poller_poller_interval_set(poller2, 16);
42    ecore_main_loop_begin();
43
44    ecore_poller_del(poller1);
45    ecore_poller_del(poller2);
46
47    ecore_shutdown();
48 }
49