diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/ecore/src/examples/ecore_poller_example.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/libraries/ecore/src/examples/ecore_poller_example.c b/libraries/ecore/src/examples/ecore_poller_example.c new file mode 100644 index 0000000..a66c069 --- /dev/null +++ b/libraries/ecore/src/examples/ecore_poller_example.c | |||
@@ -0,0 +1,47 @@ | |||
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 main(int argc, char **argv) | ||
17 | { | ||
18 | double interval = 0.3; // tick each 0.3 seconds | ||
19 | Ecore_Poller *poller1, *poller2; | ||
20 | char *str1 = "poller1"; | ||
21 | char *str2 = "poller2"; | ||
22 | |||
23 | if (!ecore_init()) | ||
24 | { | ||
25 | printf("ERROR: Cannot init Ecore!\n"); | ||
26 | return -1; | ||
27 | } | ||
28 | |||
29 | _initial_time = ecore_time_get(); | ||
30 | |||
31 | ecore_poller_poll_interval_set(ECORE_POLLER_CORE, interval); | ||
32 | |||
33 | poller1 = ecore_poller_add(ECORE_POLLER_CORE, 4, _poller_print_cb, str1); | ||
34 | poller2 = ecore_poller_add(ECORE_POLLER_CORE, 8, _poller_print_cb, str2); | ||
35 | |||
36 | ecore_main_loop_begin(); | ||
37 | |||
38 | printf("changing poller2 interval to 16\n"); | ||
39 | |||
40 | ecore_poller_poller_interval_set(poller2, 16); | ||
41 | ecore_main_loop_begin(); | ||
42 | |||
43 | ecore_poller_del(poller1); | ||
44 | ecore_poller_del(poller2); | ||
45 | |||
46 | ecore_shutdown(); | ||
47 | } | ||