aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2016-04-21 21:07:16 (GMT)
committerCedric BAIL <cedric@osg.samsung.com>2016-04-21 21:07:49 (GMT)
commit5c87f2762fca7b4adc8940e1d77a4fdc6a214562 (patch)
tree3a0f18a7ce92bedd82d4f53bd2ec004b92d9829f
parentecore: allow for possible factorization of all idler event. (diff)
downloadefl-5c87f2762fca7b4adc8940e1d77a4fdc6a214562.tar.gz
ecore: use new refactorized idle infrastructure to make idle enterer rely on mainloop events
-rw-r--r--src/Makefile_Ecore.am1
-rw-r--r--src/lib/ecore/Ecore_Common.h2
-rw-r--r--src/lib/ecore/Ecore_Eo.h1
-rw-r--r--src/lib/ecore/ecore.c1
-rw-r--r--src/lib/ecore/ecore_idle_enterer.c200
-rw-r--r--src/lib/ecore/ecore_idle_enterer.eo36
-rw-r--r--src/lib/ecore/ecore_main.c14
-rw-r--r--src/lib/ecore/ecore_private.h4
8 files changed, 22 insertions, 237 deletions
diff --git a/src/Makefile_Ecore.am b/src/Makefile_Ecore.am
index 1411945..048787e 100644
--- a/src/Makefile_Ecore.am
+++ b/src/Makefile_Ecore.am
@@ -6,7 +6,6 @@ ecore_eolian_files_legacy = \
lib/ecore/ecore_poller.eo \
lib/ecore/ecore_job.eo \
lib/ecore/ecore_exe.eo \
- lib/ecore/ecore_idle_enterer.eo \
lib/ecore/ecore_idle_exiter.eo \
lib/ecore/ecore_animator.eo
diff --git a/src/lib/ecore/Ecore_Common.h b/src/lib/ecore/Ecore_Common.h
index 4585d6b..b86f64e 100644
--- a/src/lib/ecore/Ecore_Common.h
+++ b/src/lib/ecore/Ecore_Common.h
@@ -3038,7 +3038,7 @@ typedef struct _Ecore_Factorized_Idle Ecore_Idler; /**< A handle for idlers */
/*
* @since 1.8
*/
-typedef Eo Ecore_Idle_Enterer; /**< A handle for idle enterers */
+typedef struct _Ecore_Factorized_Idle Ecore_Idle_Enterer; /**< A handle for idle enterers */
#define _ECORE_IDLE_ENTERER_EO_CLASS_TYPE
diff --git a/src/lib/ecore/Ecore_Eo.h b/src/lib/ecore/Ecore_Eo.h
index 1dce5fd..06de921 100644
--- a/src/lib/ecore/Ecore_Eo.h
+++ b/src/lib/ecore/Ecore_Eo.h
@@ -48,7 +48,6 @@ extern "C" {
*/
#include "ecore_idle_exiter.eo.h"
-#include "ecore_idle_enterer.eo.h"
/**
* @}
diff --git a/src/lib/ecore/ecore.c b/src/lib/ecore/ecore.c
index 48d823f..6709d23 100644
--- a/src/lib/ecore/ecore.c
+++ b/src/lib/ecore/ecore.c
@@ -400,7 +400,6 @@ ecore_shutdown(void)
#ifndef HAVE_EXOTIC
_ecore_exe_shutdown();
#endif
- _ecore_idle_enterer_shutdown();
_ecore_idle_exiter_shutdown();
_ecore_timer_shutdown();
_ecore_event_shutdown();
diff --git a/src/lib/ecore/ecore_idle_enterer.c b/src/lib/ecore/ecore_idle_enterer.c
index 2acf290..5bcbab8 100644
--- a/src/lib/ecore/ecore_idle_enterer.c
+++ b/src/lib/ecore/ecore_idle_enterer.c
@@ -9,68 +9,16 @@
#include "Ecore.h"
#include "ecore_private.h"
-#define MY_CLASS ECORE_IDLE_ENTERER_CLASS
+EO_CALLBACKS_ARRAY_DEFINE(ecore_idle_enterer_callbacks,
+ { ECORE_MAINLOOP_EVENT_IDLE_ENTER, _ecore_factorized_idle_process },
+ { EO_BASE_EVENT_DEL, _ecore_factorized_idle_event_del });
-#define MY_CLASS_NAME "Ecore_Idle_Enterer"
-
-struct _Ecore_Idle_Enterer_Data
-{
- EINA_INLIST;
- Ecore_Idle_Enterer *obj;
- Ecore_Task_Cb func;
- void *data;
- int references;
- Eina_Bool delete_me : 1;
-};
-typedef struct _Ecore_Idle_Enterer_Data Ecore_Idle_Enterer_Data;
-
-static Ecore_Idle_Enterer_Data *idle_enterers = NULL;
-static Ecore_Idle_Enterer_Data *idle_enterer_current = NULL;
-static int idle_enterers_delete_me = 0;
-
-static void *
-_ecore_idle_enterer_del(Ecore_Idle_Enterer *idle_enterer);
-
-static Eina_Bool
-_ecore_idle_enterer_add(Ecore_Idle_Enterer *obj,
- Ecore_Idle_Enterer_Data *ie,
- Ecore_Task_Cb func,
- const void *data)
-{
- if (EINA_UNLIKELY(!eina_main_loop_is()))
- {
- EINA_MAIN_LOOP_CHECK_RETURN_VAL(EINA_FALSE);
- }
-
- ie->obj = obj;
- eo_manual_free_set(obj, EINA_TRUE);
-
- if (!func)
- {
- ERR("callback function must be set up for an object of class: '%s'", MY_CLASS_NAME);
- return EINA_FALSE;
- }
-
- ie->func = func;
- ie->data = (void *)data;
- return EINA_TRUE;
-}
EAPI Ecore_Idle_Enterer *
ecore_idle_enterer_add(Ecore_Task_Cb func,
const void *data)
{
- Ecore_Idle_Enterer *ie = NULL;
- ie = eo_add(MY_CLASS, _ecore_parent, ecore_idle_enterer_after_constructor(eo_self, func, data));
- return ie;
-}
-
-EOLIAN static void
-_ecore_idle_enterer_after_constructor(Eo *obj, Ecore_Idle_Enterer_Data *ie, Ecore_Task_Cb func, const void *data)
-{
- if (!_ecore_idle_enterer_add(obj, ie, func, data)) return;
-
- idle_enterers = (Ecore_Idle_Enterer_Data *)eina_inlist_append(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(ie));
+ return _ecore_factorized_idle_add(ecore_idle_enterer_callbacks(), func, data);
}
EAPI Ecore_Idle_Enterer *
@@ -78,146 +26,24 @@ ecore_idle_enterer_before_add(Ecore_Task_Cb func,
const void *data)
{
Ecore_Idle_Enterer *ie = NULL;
- ie = eo_add(MY_CLASS, _ecore_parent, ecore_idle_enterer_before_constructor(eo_self, func, data));
- return ie;
-}
+ ie = _ecore_factorized_idle_add(ecore_idle_enterer_callbacks(), func, data);
-EOLIAN static void
-_ecore_idle_enterer_before_constructor(Eo *obj, Ecore_Idle_Enterer_Data *ie, Ecore_Task_Cb func, const void *data)
-{
- if (!_ecore_idle_enterer_add(obj, ie, func, data)) return;
+ // This avoid us duplicating code and should only be slightly slower
+ // due to a useless cycle of callback registration
+ eo_event_callback_array_del(_mainloop_singleton, ecore_idle_enterer_callbacks(), ie);
+ eo_event_callback_array_priority_add(_mainloop_singleton, ecore_idle_enterer_callbacks(), EO_CALLBACK_PRIORITY_BEFORE, ie);
- idle_enterers = (Ecore_Idle_Enterer_Data *)eina_inlist_prepend(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(ie));
+ return ie;
}
EAPI void *
ecore_idle_enterer_del(Ecore_Idle_Enterer *idle_enterer)
{
- if (!idle_enterer) return NULL;
- EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
-
- return _ecore_idle_enterer_del(idle_enterer);
-}
-
-static void *
-_ecore_idle_enterer_del(Ecore_Idle_Enterer *obj)
-{
- Ecore_Idle_Enterer_Data *idle_enterer = eo_data_scope_get(obj, MY_CLASS);
-
- if (!idle_enterer) return NULL;
- EINA_SAFETY_ON_TRUE_RETURN_VAL(idle_enterer->delete_me, NULL);
- idle_enterer->delete_me = 1;
- idle_enterers_delete_me = 1;
- return idle_enterer->data;
-}
-
-EOLIAN static void
-_ecore_idle_enterer_eo_base_destructor(Eo *obj, Ecore_Idle_Enterer_Data *idle_enterer)
-{
- idle_enterer->delete_me = 1;
- idle_enterers_delete_me = 1;
-
- eo_destructor(eo_super(obj, MY_CLASS));
-}
-
-EOLIAN static Eo *
-_ecore_idle_enterer_eo_base_finalize(Eo *obj, Ecore_Idle_Enterer_Data *idle_enterer)
-{
- if (!idle_enterer->func)
- {
- return NULL;
- }
-
- return eo_finalize(eo_super(obj, MY_CLASS));
+ return _ecore_factorized_idle_del(idle_enterer);
}
void
-_ecore_idle_enterer_shutdown(void)
+_ecore_idle_enterer_call(Eo *loop)
{
- Ecore_Idle_Enterer_Data *ie;
- while ((ie = idle_enterers))
- {
- idle_enterers = (Ecore_Idle_Enterer_Data *)eina_inlist_remove(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(idle_enterers));
-
- eo_parent_set(ie->obj, NULL);
- if (eo_destructed_is(ie->obj))
- eo_manual_free(ie->obj);
- else
- eo_manual_free_set(ie->obj, EINA_FALSE);
- }
- idle_enterers_delete_me = 0;
- idle_enterer_current = NULL;
+ eo_event_callback_call(loop, ECORE_MAINLOOP_EVENT_IDLE_ENTER, NULL);
}
-
-void
-_ecore_idle_enterer_call(void)
-{
- if (!idle_enterer_current)
- {
- /* regular main loop, start from head */
- idle_enterer_current = idle_enterers;
- }
- else
- {
- /* recursive main loop, continue from where we were */
- idle_enterer_current =
- (Ecore_Idle_Enterer_Data *)EINA_INLIST_GET(idle_enterer_current)->next;
- }
-
- while (idle_enterer_current)
- {
- Ecore_Idle_Enterer_Data *ie = (Ecore_Idle_Enterer_Data *)idle_enterer_current;
- if (!ie->delete_me)
- {
- ie->references++;
- eina_evlog("+idle_enterer", ie, 0.0, NULL);
- if (!_ecore_call_task_cb(ie->func, ie->data))
- {
- if (!ie->delete_me) _ecore_idle_enterer_del(ie->obj);
- }
- eina_evlog("-idle_enterer", ie, 0.0, NULL);
- ie->references--;
- }
- if (idle_enterer_current) /* may have changed in recursive main loops */
- idle_enterer_current =
- (Ecore_Idle_Enterer_Data *)EINA_INLIST_GET(idle_enterer_current)->next;
- }
- if (idle_enterers_delete_me)
- {
- Ecore_Idle_Enterer_Data *l;
- int deleted_idler_enterers_in_use = 0;
-
- for (l = idle_enterers; l; )
- {
- Ecore_Idle_Enterer_Data *ie = l;
- l = (Ecore_Idle_Enterer_Data *)EINA_INLIST_GET(l)->next;
- if (ie->delete_me)
- {
- if (ie->references)
- {
- deleted_idler_enterers_in_use++;
- continue;
- }
-
- idle_enterers = (Ecore_Idle_Enterer_Data *)eina_inlist_remove(EINA_INLIST_GET(idle_enterers), EINA_INLIST_GET(ie));
-
- eo_parent_set(ie->obj, NULL);
- if (eo_destructed_is(ie->obj))
- eo_manual_free(ie->obj);
- else
- eo_manual_free_set(ie->obj, EINA_FALSE);
- }
- }
- if (!deleted_idler_enterers_in_use)
- idle_enterers_delete_me = 0;
- }
-}
-
-int
-_ecore_idle_enterer_exist(void)
-{
- if (idle_enterers) return 1;
- return 0;
-}
-
-#include "ecore_idle_enterer.eo.c"
diff --git a/src/lib/ecore/ecore_idle_enterer.eo b/src/lib/ecore/ecore_idle_enterer.eo
deleted file mode 100644
index 39e7a70..0000000
--- a/src/lib/ecore/ecore_idle_enterer.eo
+++ /dev/null
@@ -1,36 +0,0 @@
-import ecore_types;
-
-class Ecore.Idle.Enterer (Eo.Base)
-{
- [[Setup callbacks to be called when the program enters the idle state.
-
- Enterer callbacks are good for updating your program's state, if it has a state engine.
- ]]
- eo_prefix: ecore_idle_enterer;
- methods {
- before_constructor {
- [[This constructor will insert the handler at the beginning of the list.]]
- legacy: null;
- params {
- @in func: Ecore_Task_Cb; [[Idle enterer callback function.]]
- @in data: const(void)*; [[Private data passed to callback functions.]]
- }
- }
- after_constructor {
- [[This constructor will insert the handler at the end of the list.]]
- legacy: null;
- params {
- @in func: Ecore_Task_Cb; [[Idle enterer callback function.]]
- @in data: const(void)*; [[Private data passed to callback functions.]]
- }
- }
- }
- implements {
- Eo.Base.destructor;
- Eo.Base.finalize;
- }
- constructors {
- .before_constructor;
- .after_constructor;
- }
-}
diff --git a/src/lib/ecore/ecore_main.c b/src/lib/ecore/ecore_main.c
index dcf3bf0..c2f77d0 100644
--- a/src/lib/ecore/ecore_main.c
+++ b/src/lib/ecore/ecore_main.c
@@ -708,7 +708,7 @@ _ecore_main_gsource_prepare(GSource *source EINA_UNUSED,
_ecore_timer_expired_timers_call(_ecore_time_loop_time);
_ecore_timer_cleanup();
- _ecore_idle_enterer_call();
+ _ecore_idle_enterer_call(_mainloop_singleton);
_ecore_throttle();
_ecore_glib_idle_enterer_called = FALSE;
@@ -891,7 +891,7 @@ _ecore_main_gsource_dispatch(GSource *source EINA_UNUSED,
_ecore_timer_expired_timers_call(_ecore_time_loop_time);
_ecore_timer_cleanup();
- _ecore_idle_enterer_call();
+ _ecore_idle_enterer_call(_mainloop_singleton);
_ecore_throttle();
_ecore_glib_idle_enterer_called = TRUE;
@@ -2084,7 +2084,7 @@ _ecore_main_loop_uv_prepare(uv_prepare_t* handle EINA_UNUSED)
if(!_ecore_main_uv_idling)
{
_ecore_main_uv_idling = EINA_TRUE;
- _ecore_idle_enterer_call();
+ _ecore_idle_enterer_call(_mainloop_singleton);
_ecore_throttle();
}
@@ -2239,7 +2239,7 @@ _ecore_main_loop_iterate_internal(int once_only)
if (_ecore_event_exist())
{
/* but first conceptually enter an idle state */
- _ecore_idle_enterer_call();
+ _ecore_idle_enterer_call(_mainloop_singleton);
_ecore_throttle();
/* now quickly poll to see which input fd's are active */
_ecore_main_select(0.0);
@@ -2264,7 +2264,7 @@ _ecore_main_loop_iterate_internal(int once_only)
else
{
/* call idle enterers ... */
- _ecore_idle_enterer_call();
+ _ecore_idle_enterer_call(_mainloop_singleton);
_ecore_throttle();
}
@@ -2284,7 +2284,7 @@ _ecore_main_loop_iterate_internal(int once_only)
if (once_only)
{
/* in once_only mode enter idle here instead and then return */
- _ecore_idle_enterer_call();
+ _ecore_idle_enterer_call(_mainloop_singleton);
_ecore_throttle();
_ecore_timer_enable_new();
goto done;
@@ -2348,7 +2348,7 @@ process_all: /*-*********************************************************/
if (once_only)
{
/* if in once_only mode handle idle exiting */
- _ecore_idle_enterer_call();
+ _ecore_idle_enterer_call(_mainloop_singleton);
_ecore_throttle();
}
diff --git a/src/lib/ecore/ecore_private.h b/src/lib/ecore/ecore_private.h
index 29d1db6..5190084 100644
--- a/src/lib/ecore/ecore_private.h
+++ b/src/lib/ecore/ecore_private.h
@@ -183,9 +183,7 @@ Eina_Bool _ecore_factorized_idle_event_del(void *data, const Eo_Event *event)
void _ecore_idler_all_call(Eo *loop);
int _ecore_idler_exist(Eo *loop);
-void _ecore_idle_enterer_shutdown(void);
-void _ecore_idle_enterer_call(void);
-int _ecore_idle_enterer_exist(void);
+void _ecore_idle_enterer_call(Eo *loop);
void _ecore_idle_exiter_shutdown(void);
void _ecore_idle_exiter_call(void);