forked from enlightenment/efl
ecore: move ecore idle exiter to relly on the factorized main loop event.
This commit is contained in:
parent
e87e501230
commit
3108f023ba
|
@ -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 = \
|
||||
|
|
|
@ -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 */
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
|
|
@ -37,18 +37,6 @@ extern "C" {
|
|||
|
||||
#include "ecore_timer.eo.h"
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup Ecore_Idle_Group
|
||||
*
|
||||
* @{
|
||||
*/
|
||||
|
||||
#include "ecore_idle_exiter.eo.h"
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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));
|
||||
return _ecore_factorized_idle_del(idle_exiter);
|
||||
}
|
||||
|
||||
void
|
||||
_ecore_idle_exiter_shutdown(void)
|
||||
_ecore_idle_exiter_call(Eo *loop)
|
||||
{
|
||||
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;
|
||||
eo_event_callback_call(loop, ECORE_MAINLOOP_EVENT_IDLE_EXIT, NULL);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if (idle_exiters) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#include "ecore_idle_exiter.eo.c"
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue