aboutsummaryrefslogtreecommitdiffstats
path: root/reference
diff options
context:
space:
mode:
authorAndy Williams <andy@andywilliams.me>2017-11-22 14:39:45 +0000
committerAndy Williams <andy@andywilliams.me>2017-11-22 14:39:45 +0000
commit4f1249466727efbbe77d08932073bdd0370e57ef (patch)
tree90b53a69a15227db15dd4012376b1c531ac07623 /reference
parentcore: Add a polling example (diff)
downloadexamples-4f1249466727efbbe77d08932073bdd0370e57ef.tar.gz
core: Tidy up some core example variables
Diffstat (limited to 'reference')
-rw-r--r--reference/c/core/src/core_idler.c17
-rw-r--r--reference/c/core/src/core_poll.c20
2 files changed, 21 insertions, 16 deletions
diff --git a/reference/c/core/src/core_idler.c b/reference/c/core/src/core_idler.c
index 3256baca..48f07a28 100644
--- a/reference/c/core/src/core_idler.c
+++ b/reference/c/core/src/core_idler.c
@@ -15,8 +15,6 @@
* We initiate a timer to exit the idle state and then exit the application
*/
-Efl_Loop_Timer *_timer;
-
// the idler enter callback
static void
_enter_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
@@ -40,26 +38,29 @@ _idler_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
// Our timer callback ticks at the specified interval to interrupt the idle state
static void
-_timer_cb(void *data, const Efl_Event *event)
+_timer_cb(void *data EINA_UNUSED, const Efl_Event *event)
{
+ Efl_Loop_Timer *timer;
+
+ timer = event->object;
printf("TIMER: timer callback called, exiting.\n");
- efl_del(_timer);
+ efl_del(timer);
efl_exit(0);
}
EAPI_MAIN void
efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
{
- Eo *loop = ev->object;
+ Efl_Loop *loop = ev->object;
efl_event_callback_add(loop, EFL_LOOP_EVENT_IDLE, _idler_cb, NULL);
efl_event_callback_add(loop, EFL_LOOP_EVENT_IDLE_ENTER, _enter_cb, NULL);
efl_event_callback_add(loop, EFL_LOOP_EVENT_IDLE_EXIT, _exit_cb, NULL);
- _timer = efl_add(EFL_LOOP_TIMER_CLASS, loop,
- efl_loop_timer_interval_set(efl_added, 0.0005));
- efl_event_callback_add(_timer, EFL_LOOP_TIMER_EVENT_TICK, _timer_cb, NULL);
+ efl_add(EFL_LOOP_TIMER_CLASS, loop,
+ efl_loop_timer_interval_set(efl_added, 0.0005),
+ efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TICK, _timer_cb, NULL));
}
EFL_MAIN()
diff --git a/reference/c/core/src/core_poll.c b/reference/c/core/src/core_poll.c
index 84f095cd..38de6a44 100644
--- a/reference/c/core/src/core_poll.c
+++ b/reference/c/core/src/core_poll.c
@@ -14,8 +14,6 @@
* Depending on your system this may not include any LOW frequency polls.
*/
-Efl_Loop_Timer *_timer;
-
// the poll callback for low frequency events
static void
_poll_low_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
@@ -40,27 +38,33 @@ _poll_high_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
// Our timer callback ticks at the specified interval to interrupt the polling
static void
-_timer_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
+_timer_cb(void *data EINA_UNUSED, const Efl_Event *event)
{
+ Efl_Loop_Timer *timer;
+
+ timer = event->object;
+
printf("\nTIMER: timer callback called, exiting.\n");
- efl_del(_timer);
+ efl_del(timer);
efl_exit(0);
}
EAPI_MAIN void
efl_main(void *data EINA_UNUSED, const Efl_Event *ev EINA_UNUSED)
{
- Eo *loop = ev->object;
+ Efl_Loop *loop = ev->object;
+ // don't buffer output this time as we're looking for immediate output
setbuf(stdout, NULL);
+
efl_event_callback_add(loop, EFL_LOOP_EVENT_POLL_LOW, _poll_low_cb, NULL);
efl_event_callback_add(loop, EFL_LOOP_EVENT_POLL_MEDIUM, _poll_med_cb, NULL);
efl_event_callback_add(loop, EFL_LOOP_EVENT_POLL_HIGH, _poll_high_cb, NULL);
- _timer = efl_add(EFL_LOOP_TIMER_CLASS, loop,
- efl_loop_timer_interval_set(efl_added, 30));
- efl_event_callback_add(_timer, EFL_LOOP_TIMER_EVENT_TICK, _timer_cb, NULL);
+ efl_add(EFL_LOOP_TIMER_CLASS, loop,
+ efl_loop_timer_interval_set(efl_added, 30),
+ efl_event_callback_add(efl_added, EFL_LOOP_TIMER_EVENT_TICK, _timer_cb, NULL));
}
EFL_MAIN()