cedric pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=3108f023ba34cd52d95de618eba0370016887797

commit 3108f023ba34cd52d95de618eba0370016887797
Author: Cedric BAIL <ced...@osg.samsung.com>
Date:   Thu Apr 21 14:44:23 2016 -0700

    ecore: move ecore idle exiter to relly on the factorized main loop event.
---
 src/Makefile_Ecore.am              |   1 -
 src/lib/ecore/Ecore_Common.h       |   4 +-
 src/lib/ecore/Ecore_Eo.h           |  12 ---
 src/lib/ecore/ecore.c              |   1 -
 src/lib/ecore/ecore_idle_exiter.c  | 175 ++-----------------------------------
 src/lib/ecore/ecore_idle_exiter.eo |  25 ------
 src/lib/ecore/ecore_main.c         |  12 +--
 src/lib/ecore/ecore_private.h      |   4 +-
 8 files changed, 15 insertions(+), 219 deletions(-)

diff --git a/src/Makefile_Ecore.am b/src/Makefile_Ecore.am
index 048787e..e3aa651 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_exiter.eo \
        lib/ecore/ecore_animator.eo
 
 ecore_eolian_files = \
diff --git a/src/lib/ecore/Ecore_Common.h b/src/lib/ecore/Ecore_Common.h
index 34ef428..04ee28d 100644
--- a/src/lib/ecore/Ecore_Common.h
+++ b/src/lib/ecore/Ecore_Common.h
@@ -3043,9 +3043,7 @@ typedef struct _Ecore_Factorized_Idle Ecore_Idle_Enterer; 
/**< A handle for idle
 /*
  * @since 1.8
  */
-typedef Eo Ecore_Idle_Exiter; /**< A handle for idle exiters */
-
-#define _ECORE_IDLE_EXITER_EO_CLASS_TYPE
+typedef struct _Ecore_Factorized_Idle Ecore_Idle_Exiter; /**< A handle for 
idle exiters */
 
 /**
  * @}
diff --git a/src/lib/ecore/Ecore_Eo.h b/src/lib/ecore/Ecore_Eo.h
index 06de921..fa256b9 100644
--- a/src/lib/ecore/Ecore_Eo.h
+++ b/src/lib/ecore/Ecore_Eo.h
@@ -42,18 +42,6 @@ extern "C" {
  */
 
 /**
- * @ingroup Ecore_Idle_Group
- *
- * @{
- */
-
-#include "ecore_idle_exiter.eo.h"
-
-/**
- * @}
- */
-
-/**
  * @ingroup Ecore_Exe_Group
  *
  * @{
diff --git a/src/lib/ecore/ecore.c b/src/lib/ecore/ecore.c
index 6709d23..43bebbe 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_exiter_shutdown();
      _ecore_timer_shutdown();
      _ecore_event_shutdown();
      _ecore_main_shutdown();
diff --git a/src/lib/ecore/ecore_idle_exiter.c 
b/src/lib/ecore/ecore_idle_exiter.c
index 7956370..07660d6 100644
--- a/src/lib/ecore/ecore_idle_exiter.c
+++ b/src/lib/ecore/ecore_idle_exiter.c
@@ -9,186 +9,25 @@
 #include "Ecore.h"
 #include "ecore_private.h"
 
-#define MY_CLASS ECORE_IDLE_EXITER_CLASS
-
-#define MY_CLASS_NAME "Ecore_Idle_Exiter"
-
-struct _Ecore_Idle_Exiter_Data
-{
-   EINA_INLIST;
-   Ecore_Idle_Exiter  *obj;
-   Ecore_Task_Cb      func;
-   void               *data;
-   int                references;
-   Eina_Bool          delete_me : 1;
-};
-
-typedef struct _Ecore_Idle_Exiter_Data Ecore_Idle_Exiter_Data;
-
-static Ecore_Idle_Exiter_Data *idle_exiters = NULL;
-static Ecore_Idle_Exiter_Data *idle_exiter_current = NULL;
-static int idle_exiters_delete_me = 0;
-
-static void *
-_ecore_idle_exiter_del(Ecore_Idle_Exiter *idle_exiter);
+EO_CALLBACKS_ARRAY_DEFINE(ecore_idle_exiter_callbacks,
+                          { ECORE_MAINLOOP_EVENT_IDLE_EXIT, 
_ecore_factorized_idle_process },
+                          { EO_BASE_EVENT_DEL, 
_ecore_factorized_idle_event_del });
 
 EAPI Ecore_Idle_Exiter *
 ecore_idle_exiter_add(Ecore_Task_Cb func,
                       const void   *data)
 {
-   Ecore_Idle_Exiter *ie = NULL;
-   ie = eo_add(MY_CLASS, _ecore_parent, ecore_idle_exiter_constructor(eo_self, 
func, data));
-   return ie;
-}
-
-EOLIAN static void
-_ecore_idle_exiter_constructor(Eo *obj, Ecore_Idle_Exiter_Data *ie, 
Ecore_Task_Cb func, const void *data)
-{
-   EINA_MAIN_LOOP_CHECK_RETURN;
-
-   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 ;
-     }
-
-   ie->func = func;
-   ie->data = (void *)data;
-
-   idle_exiters = (Ecore_Idle_Exiter_Data 
*)eina_inlist_append(EINA_INLIST_GET(idle_exiters), EINA_INLIST_GET(ie));
+   return  _ecore_factorized_idle_add(ecore_idle_exiter_callbacks(), func, 
data);
 }
 
 EAPI void *
 ecore_idle_exiter_del(Ecore_Idle_Exiter *idle_exiter)
 {
-   if (!idle_exiter) return NULL;
-   EINA_MAIN_LOOP_CHECK_RETURN_VAL(NULL);
-
-   return _ecore_idle_exiter_del(idle_exiter);
-}
-
-static void *
-_ecore_idle_exiter_del(Ecore_Idle_Exiter *obj)
-{
-   Ecore_Idle_Exiter_Data *idle_exiter = eo_data_scope_get(obj, MY_CLASS);
-   EINA_SAFETY_ON_TRUE_RETURN_VAL(idle_exiter->delete_me, NULL);
-   idle_exiter->delete_me = 1;
-   idle_exiters_delete_me = 1;
-   return idle_exiter->data;
-}
-
-EOLIAN static Eo *
-_ecore_idle_exiter_eo_base_finalize(Eo *obj, Ecore_Idle_Exiter_Data 
*idle_exiter)
-{
-   if (!idle_exiter->func)
-     {
-        return NULL;
-     }
-
-   return eo_finalize(eo_super(obj, MY_CLASS));
-}
-
-EOLIAN static void
-_ecore_idle_exiter_eo_base_destructor(Eo *obj, Ecore_Idle_Exiter_Data 
*idle_exiter)
-{
-
-   idle_exiter->delete_me = 1;
-   idle_exiters_delete_me = 1;
-
-   eo_destructor(eo_super(obj, MY_CLASS));
-}
-
-void
-_ecore_idle_exiter_shutdown(void)
-{
-   Ecore_Idle_Exiter_Data *ie;
-   while ((ie = idle_exiters))
-     {
-        idle_exiters = (Ecore_Idle_Exiter_Data 
*)eina_inlist_remove(EINA_INLIST_GET(idle_exiters), 
EINA_INLIST_GET(idle_exiters));
-
-        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_exiters_delete_me = 0;
-   idle_exiter_current = NULL;
+   return _ecore_factorized_idle_del(idle_exiter);
 }
 
 void
-_ecore_idle_exiter_call(void)
-{
-   if (!idle_exiter_current)
-     {
-        /* regular main loop, start from head */
-         idle_exiter_current = idle_exiters;
-     }
-   else
-     {
-        /* recursive main loop, continue from where we were */
-         idle_exiter_current =
-           (Ecore_Idle_Exiter_Data 
*)EINA_INLIST_GET(idle_exiter_current)->next;
-     }
-
-   while (idle_exiter_current)
-     {
-        Ecore_Idle_Exiter_Data *ie = (Ecore_Idle_Exiter_Data 
*)idle_exiter_current;
-        if (!ie->delete_me)
-          {
-             ie->references++;
-             eina_evlog("+idle_exiter", ie, 0.0, NULL);
-             if (!_ecore_call_task_cb(ie->func, ie->data))
-               {
-                  if (!ie->delete_me) _ecore_idle_exiter_del(ie->obj);
-               }
-             eina_evlog("-idle_exiter", ie, 0.0, NULL);
-             ie->references--;
-          }
-        if (idle_exiter_current) /* may have changed in recursive main loops */
-          idle_exiter_current =
-            (Ecore_Idle_Exiter_Data 
*)EINA_INLIST_GET(idle_exiter_current)->next;
-     }
-   if (idle_exiters_delete_me)
-     {
-        Ecore_Idle_Exiter_Data *l;
-        int deleted_idler_exiters_in_use = 0;
-
-        for (l = idle_exiters; l; )
-          {
-             Ecore_Idle_Exiter_Data *ie = l;
-
-             l = (Ecore_Idle_Exiter_Data *)EINA_INLIST_GET(l)->next;
-             if (ie->delete_me)
-               {
-                  if (ie->references)
-                    {
-                       deleted_idler_exiters_in_use++;
-                       continue;
-                    }
-
-                  idle_exiters = (Ecore_Idle_Exiter_Data 
*)eina_inlist_remove(EINA_INLIST_GET(idle_exiters), 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_exiters_in_use)
-          idle_exiters_delete_me = 0;
-     }
-}
-
-int
-_ecore_idle_exiter_exist(void)
+_ecore_idle_exiter_call(Eo *loop)
 {
-   if (idle_exiters) return 1;
-   return 0;
+   eo_event_callback_call(loop, ECORE_MAINLOOP_EVENT_IDLE_EXIT, NULL);
 }
-
-#include "ecore_idle_exiter.eo.c"
diff --git a/src/lib/ecore/ecore_idle_exiter.eo 
b/src/lib/ecore/ecore_idle_exiter.eo
deleted file mode 100644
index d866599..0000000
--- a/src/lib/ecore/ecore_idle_exiter.eo
+++ /dev/null
@@ -1,25 +0,0 @@
-import ecore_types;
-
-class Ecore.Idle.Exiter (Eo.Base)
-{
-   [[Setup callbacks to be called when the program exits the idle state.]]
-
-   eo_prefix: ecore_idle_exiter;
-   methods {
-      constructor {
-         [[Constructor.]]
-         legacy: null;
-         params {
-            @in func: Ecore_Task_Cb; [[Idle exiter callback function.]]
-            @in data: const(void)*; [[Private data passed to callback 
functions.]]
-         }
-      }
-   }
-   implements {
-      Eo.Base.destructor;
-      Eo.Base.finalize;
-   }
-   constructors {
-      .constructor;
-   }
-}
diff --git a/src/lib/ecore/ecore_main.c b/src/lib/ecore/ecore_main.c
index c2f77d0..09f7685 100644
--- a/src/lib/ecore/ecore_main.c
+++ b/src/lib/ecore/ecore_main.c
@@ -441,7 +441,7 @@ _ecore_main_uv_poll_cb(uv_poll_t* handle, int status, int 
events)
      {
        DBG("not IDLE anymore");
        _ecore_main_uv_idling = EINA_FALSE;
-       _ecore_idle_exiter_call();
+       _ecore_idle_exiter_call(_mainloop_singleton);
        _ecore_animator_run_reset();
      }
   
@@ -856,7 +856,7 @@ _ecore_main_gsource_dispatch(GSource    *source EINA_UNUSED,
    if (ecore_idling && events_ready)
      {
         _ecore_animator_run_reset();
-        _ecore_idle_exiter_call();
+        _ecore_idle_exiter_call(_mainloop_singleton);
         ecore_idling = 0;
      }
    else if (!ecore_idling && !events_ready)
@@ -873,7 +873,7 @@ _ecore_main_gsource_dispatch(GSource    *source EINA_UNUSED,
         if (ecore_fds_ready || events_ready || timers_ready)
           {
              _ecore_animator_run_reset();
-             _ecore_idle_exiter_call();
+             _ecore_idle_exiter_call(_mainloop_singleton);
              ecore_idling = 0;
           }
      }
@@ -994,7 +994,7 @@ void _ecore_main_loop_timer_run(uv_timer_t* timer 
EINA_UNUSED)
   if(_ecore_main_uv_idling)
     {
       _ecore_main_uv_idling = EINA_FALSE;
-      _ecore_idle_exiter_call();
+      _ecore_idle_exiter_call(_mainloop_singleton);
       _ecore_animator_run_reset();
     }
   _ecore_time_loop_time = ecore_time_get();
@@ -2103,7 +2103,7 @@ _ecore_main_loop_uv_prepare(uv_prepare_t* handle 
EINA_UNUSED)
 
        if(_ecore_main_uv_idling)
          {
-            _ecore_idle_exiter_call();
+            _ecore_idle_exiter_call(_mainloop_singleton);
             _ecore_animator_run_reset();
 
             _ecore_main_uv_idling = EINA_FALSE;
@@ -2332,7 +2332,7 @@ process_all: 
/*-*********************************************************/
    if (!once_only)
      {
         _ecore_animator_run_reset();
-        _ecore_idle_exiter_call();
+        _ecore_idle_exiter_call(_mainloop_singleton);
      }
    /* call the fd handler per fd that became alive... */
    /* this should read or write any data to the monitored fd and then */
diff --git a/src/lib/ecore/ecore_private.h b/src/lib/ecore/ecore_private.h
index 5190084..62c6578 100644
--- a/src/lib/ecore/ecore_private.h
+++ b/src/lib/ecore/ecore_private.h
@@ -185,9 +185,7 @@ int          _ecore_idler_exist(Eo *loop);
 
 void         _ecore_idle_enterer_call(Eo *loop);
 
-void         _ecore_idle_exiter_shutdown(void);
-void         _ecore_idle_exiter_call(void);
-int          _ecore_idle_exiter_exist(void);
+void         _ecore_idle_exiter_call(Eo *loop);
 
 void         _ecore_event_shutdown(void);
 int          _ecore_event_exist(void);

-- 


Reply via email to