ecore: Efl.Timer should be Efl.Loop.Timer for coherence.

As we add more object in the main loop, they can't live in the top
namespace as they make little sense there (Efl.Fd !). For coherence,
everyone should in the loop namespace, so move timer there.
This commit is contained in:
Cedric BAIL 2016-06-03 16:01:08 -07:00
parent 5cc16b1c29
commit b3d56820d5
8 changed files with 123 additions and 123 deletions

View File

@ -4,7 +4,7 @@
ecore_eolian_files_legacy = \ ecore_eolian_files_legacy = \
lib/ecore/ecore_poller.eo \ lib/ecore/ecore_poller.eo \
lib/ecore/ecore_exe.eo \ lib/ecore/ecore_exe.eo \
lib/ecore/efl_timer.eo lib/ecore/efl_loop_timer.eo
ecore_eolian_files = \ ecore_eolian_files = \
lib/ecore/efl_loop.eo \ lib/ecore/efl_loop.eo \

View File

@ -23,7 +23,7 @@ extern "C" {
* @{ * @{
*/ */
#include "efl_timer.eo.h" #include "efl_loop_timer.eo.h"
/** /**
* @} * @}

View File

@ -235,7 +235,7 @@ EAPI Eina_Bool ecore_timer_freeze_get(Ecore_Timer *timer);
EAPI void ecore_timer_thaw(Ecore_Timer *timer); EAPI void ecore_timer_thaw(Ecore_Timer *timer);
#include "efl_timer.eo.legacy.h" #include "efl_loop_timer.eo.legacy.h"
/** /**
* @} * @}

View File

@ -406,7 +406,7 @@ ecore_shutdown(void)
#ifndef HAVE_EXOTIC #ifndef HAVE_EXOTIC
_ecore_exe_shutdown(); _ecore_exe_shutdown();
#endif #endif
_efl_timer_shutdown(); _efl_loop_timer_shutdown();
_ecore_event_shutdown(); _ecore_event_shutdown();
_ecore_main_shutdown(); _ecore_main_shutdown();
_ecore_signal_shutdown(); _ecore_signal_shutdown();

View File

@ -460,7 +460,7 @@ _ecore_main_uv_poll_cb(uv_poll_t* handle, int status, int events)
_ecore_signal_received_process(); _ecore_signal_received_process();
_ecore_event_call(); _ecore_event_call();
_ecore_main_fd_handlers_cleanup(); _ecore_main_fd_handlers_cleanup();
_efl_timer_expired_timers_call(_ecore_time_loop_time); _efl_loop_timer_expired_timers_call(_ecore_time_loop_time);
} }
static int static int
@ -704,7 +704,7 @@ _ecore_main_gsource_prepare(GSource *source EINA_UNUSED,
if (!ecore_idling && !_ecore_glib_idle_enterer_called) if (!ecore_idling && !_ecore_glib_idle_enterer_called)
{ {
_ecore_time_loop_time = ecore_time_get(); _ecore_time_loop_time = ecore_time_get();
_efl_timer_expired_timers_call(_ecore_time_loop_time); _efl_loop_timer_expired_timers_call(_ecore_time_loop_time);
_ecore_idle_enterer_call(_mainloop_singleton); _ecore_idle_enterer_call(_mainloop_singleton);
_ecore_throttle(); _ecore_throttle();
@ -722,10 +722,10 @@ _ecore_main_gsource_prepare(GSource *source EINA_UNUSED,
/* only set idling state in dispatch */ /* only set idling state in dispatch */
if (ecore_idling && !_ecore_idler_exist(_mainloop_singleton) && !_ecore_event_exist()) if (ecore_idling && !_ecore_idler_exist(_mainloop_singleton) && !_ecore_event_exist())
{ {
if (_efl_timers_exists()) if (_efl_loop_timers_exists())
{ {
int r = -1; int r = -1;
double t = _efl_timer_next_get(); double t = _efl_loop_timer_next_get();
if (timer_fd >= 0 && t > 0.0) if (timer_fd >= 0 && t > 0.0)
{ {
struct itimerspec ts; struct itimerspec ts;
@ -821,8 +821,8 @@ _ecore_main_gsource_check(GSource *source EINA_UNUSED)
ret = TRUE; ret = TRUE;
/* check timers after updating loop time */ /* check timers after updating loop time */
if (!ret && _efl_timers_exists()) if (!ret && _efl_loop_timers_exists())
ret = (0.0 == _efl_timer_next_get()); ret = (0.0 == _efl_loop_timer_next_get());
in_main_loop--; in_main_loop--;
@ -839,11 +839,11 @@ _ecore_main_gsource_dispatch(GSource *source EINA_UNUSED,
double next_time; double next_time;
_ecore_time_loop_time = ecore_time_get(); _ecore_time_loop_time = ecore_time_get();
_efl_timer_enable_new(); _efl_loop_timer_enable_new();
next_time = _efl_timer_next_get(); next_time = _efl_loop_timer_next_get();
events_ready = _ecore_event_exist(); events_ready = _ecore_event_exist();
timers_ready = _efl_timers_exists() && (0.0 == next_time); timers_ready = _efl_loop_timers_exists() && (0.0 == next_time);
idlers_ready = _ecore_idler_exist(_mainloop_singleton); idlers_ready = _ecore_idler_exist(_mainloop_singleton);
in_main_loop++; in_main_loop++;
@ -886,7 +886,7 @@ _ecore_main_gsource_dispatch(GSource *source EINA_UNUSED,
_ecore_event_call(); _ecore_event_call();
_ecore_main_fd_handlers_cleanup(); _ecore_main_fd_handlers_cleanup();
_efl_timer_expired_timers_call(_ecore_time_loop_time); _efl_loop_timer_expired_timers_call(_ecore_time_loop_time);
_ecore_idle_enterer_call(_mainloop_singleton); _ecore_idle_enterer_call(_mainloop_singleton);
_ecore_throttle(); _ecore_throttle();
@ -1019,7 +1019,7 @@ _ecore_main_loop_uv_check(uv_check_t* handle EINA_UNUSED)
_ecore_signal_received_process(); _ecore_signal_received_process();
_ecore_event_call(); _ecore_event_call();
_ecore_main_fd_handlers_cleanup(); _ecore_main_fd_handlers_cleanup();
_efl_timer_expired_timers_call(_ecore_time_loop_time); _efl_loop_timer_expired_timers_call(_ecore_time_loop_time);
} }
while(fd_handlers_to_call); while(fd_handlers_to_call);
quit: quit:
@ -2110,7 +2110,7 @@ _ecore_main_loop_uv_prepare(uv_prepare_t* handle EINA_UNUSED)
t = -1; t = -1;
_ecore_time_loop_time = ecore_time_get(); _ecore_time_loop_time = ecore_time_get();
_efl_timer_enable_new(); _efl_loop_timer_enable_new();
goto done; goto done;
} }
@ -2118,10 +2118,10 @@ _ecore_main_loop_uv_prepare(uv_prepare_t* handle EINA_UNUSED)
assert(!fd_handlers_to_call); assert(!fd_handlers_to_call);
_ecore_time_loop_time = ecore_time_get(); _ecore_time_loop_time = ecore_time_get();
_efl_timer_enable_new(); _efl_loop_timer_enable_new();
if (_efl_timers_exists() || t >= 0) if (_efl_loop_timers_exists() || t >= 0)
{ {
double t1 = _efl_timer_next_get(); double t1 = _efl_loop_timer_next_get();
if(t < 0 || (t1 >= 0 && t1 < t)) t = t1; if(t < 0 || (t1 >= 0 && t1 < t)) t = t1;
DBG("Should awake after %f", t); DBG("Should awake after %f", t);
@ -2181,7 +2181,7 @@ _ecore_main_loop_spin_no_timers(void)
if (action != SPIN_MORE) return action; if (action != SPIN_MORE) return action;
/* if an idler has added a timer then we need to go through /* if an idler has added a timer then we need to go through
* the start of the spin cycle again to handle cases properly */ * the start of the spin cycle again to handle cases properly */
if (_efl_timers_exists()) return SPIN_RESTART; if (_efl_loop_timers_exists()) return SPIN_RESTART;
} }
/* just contiune handling events etc. */ /* just contiune handling events etc. */
return LOOP_CONTINUE; return LOOP_CONTINUE;
@ -2199,7 +2199,7 @@ _ecore_main_loop_spin_timers(void)
/* if next timer expires now or in the past - stop spinning and /* if next timer expires now or in the past - stop spinning and
* continue the mainloop walk as our "select" timeout has * continue the mainloop walk as our "select" timeout has
* expired now */ * expired now */
if (_efl_timer_next_get() <= 0.0) return LOOP_CONTINUE; if (_efl_loop_timer_next_get() <= 0.0) return LOOP_CONTINUE;
} }
/* just contiune handling events etc. */ /* just contiune handling events etc. */
return LOOP_CONTINUE; return LOOP_CONTINUE;
@ -2227,7 +2227,7 @@ _ecore_main_loop_iterate_internal(int once_only)
in_main_loop++; in_main_loop++;
/* expire any timers */ /* expire any timers */
_efl_timer_expired_timers_call(_ecore_time_loop_time); _efl_loop_timer_expired_timers_call(_ecore_time_loop_time);
/* process signals into events .... */ /* process signals into events .... */
_ecore_signal_received_process(); _ecore_signal_received_process();
@ -2241,7 +2241,7 @@ _ecore_main_loop_iterate_internal(int once_only)
/* now quickly poll to see which input fd's are active */ /* now quickly poll to see which input fd's are active */
_ecore_main_select(0.0); _ecore_main_select(0.0);
/* allow newly queued timers to expire from now on */ /* allow newly queued timers to expire from now on */
_efl_timer_enable_new(); _efl_loop_timer_enable_new();
/* go straight to processing the events we had queued */ /* go straight to processing the events we had queued */
goto process_all; goto process_all;
} }
@ -2254,7 +2254,7 @@ _ecore_main_loop_iterate_internal(int once_only)
* merged together */ * merged together */
if (_ecore_main_select(0.0) | _ecore_signal_count_get()) if (_ecore_main_select(0.0) | _ecore_signal_count_get())
{ {
_efl_timer_enable_new(); _efl_loop_timer_enable_new();
goto process_all; goto process_all;
} }
} }
@ -2274,7 +2274,7 @@ _ecore_main_loop_iterate_internal(int once_only)
if (_ecore_event_exist()) if (_ecore_event_exist())
{ {
_ecore_main_select(0.0); _ecore_main_select(0.0);
_efl_timer_enable_new(); _efl_loop_timer_enable_new();
goto process_all; goto process_all;
} }
@ -2283,7 +2283,7 @@ _ecore_main_loop_iterate_internal(int once_only)
/* in once_only mode enter idle here instead and then return */ /* in once_only mode enter idle here instead and then return */
_ecore_idle_enterer_call(_mainloop_singleton); _ecore_idle_enterer_call(_mainloop_singleton);
_ecore_throttle(); _ecore_throttle();
_efl_timer_enable_new(); _efl_loop_timer_enable_new();
goto done; goto done;
} }
@ -2292,17 +2292,17 @@ _ecore_main_loop_iterate_internal(int once_only)
/* start of the sleeping or looping section */ /* start of the sleeping or looping section */
start_loop: /*-*************************************************************/ start_loop: /*-*************************************************************/
/* any timers re-added as a result of these are allowed to go */ /* any timers re-added as a result of these are allowed to go */
_efl_timer_enable_new(); _efl_loop_timer_enable_new();
/* if we have been asked to quit the mainloop then exit at this point */ /* if we have been asked to quit the mainloop then exit at this point */
if (do_quit) if (do_quit)
{ {
_efl_timer_enable_new(); _efl_loop_timer_enable_new();
goto done; goto done;
} }
if (!_ecore_event_exist()) if (!_ecore_event_exist())
{ {
/* init flags */ /* init flags */
next_time = _efl_timer_next_get(); next_time = _efl_loop_timer_next_get();
/* no idlers */ /* no idlers */
if (!_ecore_idler_exist(_mainloop_singleton)) if (!_ecore_idler_exist(_mainloop_singleton))
{ {
@ -2807,7 +2807,7 @@ struct _Efl_Internal_Promise
{ {
union { union {
Ecore_Job *job; Ecore_Job *job;
Efl_Timer *timer; Efl_Loop_Timer *timer;
} u; } u;
Eina_Promise_Owner *promise; Eina_Promise_Owner *promise;
@ -2930,7 +2930,7 @@ _efl_loop_timeout_force_cancel_cb(void *data, const Eo_Event *event EINA_UNUSED)
} }
EO_CALLBACKS_ARRAY_DEFINE(timeout, EO_CALLBACKS_ARRAY_DEFINE(timeout,
{ EFL_TIMER_EVENT_TICK, _efl_loop_timeout_cb }, { EFL_LOOP_TIMER_EVENT_TICK, _efl_loop_timeout_cb },
{ EO_EVENT_DEL, _efl_loop_timeout_force_cancel_cb }); { EO_EVENT_DEL, _efl_loop_timeout_force_cancel_cb });
static Eina_Promise * static Eina_Promise *
@ -2946,8 +2946,8 @@ _efl_loop_timeout(Eo *obj, Efl_Loop_Data *pd EINA_UNUSED, double time, const voi
if (!t) goto on_error; if (!t) goto on_error;
t->job_is = EINA_FALSE; t->job_is = EINA_FALSE;
t->u.timer = eo_add(EFL_TIMER_CLASS, obj, t->u.timer = eo_add(EFL_LOOP_TIMER_CLASS, obj,
efl_timer_interval_set(eo_self, time), efl_loop_timer_interval_set(eo_self, time),
eo_event_callback_array_add(eo_self, timeout(), t)); eo_event_callback_array_add(eo_self, timeout(), t));
if (!t->u.timer) goto on_error; if (!t->u.timer) goto on_error;

View File

@ -150,14 +150,14 @@ EAPI void _ecore_magic_fail(const void *d,
void _ecore_time_init(void); void _ecore_time_init(void);
void *_efl_timer_del(Ecore_Timer *timer); void *_efl_loop_timer_del(Ecore_Timer *timer);
void _efl_timer_shutdown(void); void _efl_loop_timer_shutdown(void);
void _efl_timer_enable_new(void); void _efl_loop_timer_enable_new(void);
double _efl_timer_next_get(void); double _efl_loop_timer_next_get(void);
void _efl_timer_expired_timers_call(double when); void _efl_loop_timer_expired_timers_call(double when);
int _efl_timers_exists(void); int _efl_loop_timers_exists(void);
int _efl_timer_expired_call(double when); int _efl_loop_timer_expired_call(double when);
Ecore_Factorized_Idle *_ecore_factorized_idle_add(const Eo_Callback_Array_Item*desc, Ecore_Factorized_Idle *_ecore_factorized_idle_add(const Eo_Callback_Array_Item*desc,
Ecore_Task_Cb func, Ecore_Task_Cb func,

View File

@ -10,14 +10,14 @@
#include "Ecore.h" #include "Ecore.h"
#include "ecore_private.h" #include "ecore_private.h"
#define MY_CLASS EFL_TIMER_CLASS #define MY_CLASS EFL_LOOP_TIMER_CLASS
#define MY_CLASS_NAME "Efl_Timer" #define MY_CLASS_NAME "Efl_Loop_Timer"
#define ECORE_TIMER_CHECK(obj) \ #define ECORE_TIMER_CHECK(obj) \
if (!eo_isa((obj), MY_CLASS)) \ if (!eo_isa((obj), MY_CLASS)) \
return return
struct _Efl_Timer_Data struct _Efl_Loop_Timer_Data
{ {
EINA_INLIST; EINA_INLIST;
@ -34,19 +34,19 @@ struct _Efl_Timer_Data
unsigned char initialized : 1; unsigned char initialized : 1;
}; };
typedef struct _Efl_Timer_Data Efl_Timer_Data; typedef struct _Efl_Loop_Timer_Data Efl_Loop_Timer_Data;
static void _efl_timer_util_delay(Efl_Timer_Data *timer, static void _efl_loop_timer_util_delay(Efl_Loop_Timer_Data *timer,
double add); double add);
static void _efl_timer_util_instanciate(Efl_Timer_Data *timer); static void _efl_loop_timer_util_instanciate(Efl_Loop_Timer_Data *timer);
static void _efl_timer_set(Efl_Timer_Data *timer, static void _efl_loop_timer_set(Efl_Loop_Timer_Data *timer,
double at, double at,
double in); double in);
static Eina_Inlist *timers = NULL; static Eina_Inlist *timers = NULL;
static Eina_Inlist *suspended = NULL; static Eina_Inlist *suspended = NULL;
static Efl_Timer_Data *timer_current = NULL; static Efl_Loop_Timer_Data *timer_current = NULL;
static int timers_added = 0; static int timers_added = 0;
@ -77,15 +77,15 @@ static Eina_Bool
_check_timer_event_catcher_add(void *data, const Eo_Event *event) _check_timer_event_catcher_add(void *data, const Eo_Event *event)
{ {
const Eo_Callback_Array_Item *array = event->info; const Eo_Callback_Array_Item *array = event->info;
Efl_Timer_Data *timer = data; Efl_Loop_Timer_Data *timer = data;
int i; int i;
for (i = 0; array[i].desc != NULL; i++) for (i = 0; array[i].desc != NULL; i++)
{ {
if (array[i].desc == EFL_TIMER_EVENT_TICK) if (array[i].desc == EFL_LOOP_TIMER_EVENT_TICK)
{ {
if (timer->listening++ > 0) return EO_CALLBACK_CONTINUE; if (timer->listening++ > 0) return EO_CALLBACK_CONTINUE;
_efl_timer_util_instanciate(timer); _efl_loop_timer_util_instanciate(timer);
// No need to walk more than once per array as you can not del // No need to walk more than once per array as you can not del
// a partial array // a partial array
return EO_CALLBACK_CONTINUE; return EO_CALLBACK_CONTINUE;
@ -99,15 +99,15 @@ static Eina_Bool
_check_timer_event_catcher_del(void *data, const Eo_Event *event) _check_timer_event_catcher_del(void *data, const Eo_Event *event)
{ {
const Eo_Callback_Array_Item *array = event->info; const Eo_Callback_Array_Item *array = event->info;
Efl_Timer_Data *timer = data; Efl_Loop_Timer_Data *timer = data;
int i; int i;
for (i = 0; array[i].desc != NULL; i++) for (i = 0; array[i].desc != NULL; i++)
{ {
if (array[i].desc == EFL_TIMER_EVENT_TICK) if (array[i].desc == EFL_LOOP_TIMER_EVENT_TICK)
{ {
if ((--timer->listening) > 0) return EO_CALLBACK_CONTINUE; if ((--timer->listening) > 0) return EO_CALLBACK_CONTINUE;
_efl_timer_util_instanciate(timer); _efl_loop_timer_util_instanciate(timer);
return EO_CALLBACK_CONTINUE; return EO_CALLBACK_CONTINUE;
} }
} }
@ -120,7 +120,7 @@ EO_CALLBACKS_ARRAY_DEFINE(timer_watch,
{ EO_EVENT_CALLBACK_DEL, _check_timer_event_catcher_del }); { EO_EVENT_CALLBACK_DEL, _check_timer_event_catcher_del });
EOLIAN static Eo * EOLIAN static Eo *
_efl_timer_eo_base_constructor(Eo *obj, Efl_Timer_Data *timer) _efl_loop_timer_eo_base_constructor(Eo *obj, Efl_Loop_Timer_Data *timer)
{ {
eo_constructor(eo_super(obj, MY_CLASS)); eo_constructor(eo_super(obj, MY_CLASS));
@ -136,9 +136,9 @@ _efl_timer_eo_base_constructor(Eo *obj, Efl_Timer_Data *timer)
EOLIAN static Eo * EOLIAN static Eo *
_efl_timer_eo_base_finalize(Eo *obj, Efl_Timer_Data *pd) _efl_loop_timer_eo_base_finalize(Eo *obj, Efl_Loop_Timer_Data *pd)
{ {
_efl_timer_util_instanciate(pd); _efl_loop_timer_util_instanciate(pd);
return eo_finalize(eo_super(obj, MY_CLASS)); return eo_finalize(eo_super(obj, MY_CLASS));
} }
@ -178,7 +178,7 @@ _ecore_timer_legacy_tick(void *data, const Eo_Event *event)
} }
EO_CALLBACKS_ARRAY_DEFINE(legacy_timer, EO_CALLBACKS_ARRAY_DEFINE(legacy_timer,
{ EFL_TIMER_EVENT_TICK, _ecore_timer_legacy_tick }, { EFL_LOOP_TIMER_EVENT_TICK, _ecore_timer_legacy_tick },
{ EO_EVENT_DEL, _ecore_timer_legacy_del }); { EO_EVENT_DEL, _ecore_timer_legacy_del });
EAPI Ecore_Timer * EAPI Ecore_Timer *
@ -197,7 +197,7 @@ ecore_timer_add(double in,
timer = eo_add(MY_CLASS, ecore_main_loop_get(), timer = eo_add(MY_CLASS, ecore_main_loop_get(),
eo_event_callback_array_add(eo_self, legacy_timer(), legacy), eo_event_callback_array_add(eo_self, legacy_timer(), legacy),
eo_key_data_set(eo_self, "_legacy", legacy), eo_key_data_set(eo_self, "_legacy", legacy),
efl_timer_interval_set(eo_self, in)); efl_loop_timer_interval_set(eo_self, in));
return timer; return timer;
} }
@ -218,8 +218,8 @@ ecore_timer_loop_add(double in,
timer = eo_add(MY_CLASS, ecore_main_loop_get(), timer = eo_add(MY_CLASS, ecore_main_loop_get(),
eo_event_callback_array_add(eo_self, legacy_timer(), legacy), eo_event_callback_array_add(eo_self, legacy_timer(), legacy),
eo_key_data_set(eo_self, "_legacy", legacy), eo_key_data_set(eo_self, "_legacy", legacy),
efl_timer_loop_reset(eo_self), efl_loop_timer_loop_reset(eo_self),
efl_timer_interval_set(eo_self, in)); efl_loop_timer_interval_set(eo_self, in));
return timer; return timer;
} }
@ -245,7 +245,7 @@ ecore_timer_del(Ecore_Timer *timer)
} }
EOLIAN static void EOLIAN static void
_efl_timer_interval_set(Eo *obj EINA_UNUSED, Efl_Timer_Data *timer, double in) _efl_loop_timer_interval_set(Eo *obj EINA_UNUSED, Efl_Loop_Timer_Data *timer, double in)
{ {
EINA_MAIN_LOOP_CHECK_RETURN; EINA_MAIN_LOOP_CHECK_RETURN;
if (in < 0.0) in = 0.0; if (in < 0.0) in = 0.0;
@ -253,11 +253,11 @@ _efl_timer_interval_set(Eo *obj EINA_UNUSED, Efl_Timer_Data *timer, double in)
timer->in = in; timer->in = in;
if (!timer->initialized) if (!timer->initialized)
_efl_timer_set(timer, timer->at + in, in); _efl_loop_timer_set(timer, timer->at + in, in);
} }
EOLIAN static double EOLIAN static double
_efl_timer_interval_get(Eo *obj EINA_UNUSED, Efl_Timer_Data *timer) _efl_loop_timer_interval_get(Eo *obj EINA_UNUSED, Efl_Loop_Timer_Data *timer)
{ {
double ret = -1.0; double ret = -1.0;
@ -268,15 +268,15 @@ _efl_timer_interval_get(Eo *obj EINA_UNUSED, Efl_Timer_Data *timer)
} }
EOLIAN static void EOLIAN static void
_efl_timer_delay(Eo *obj EINA_UNUSED, Efl_Timer_Data *pd, double add) _efl_loop_timer_delay(Eo *obj EINA_UNUSED, Efl_Loop_Timer_Data *pd, double add)
{ {
EINA_MAIN_LOOP_CHECK_RETURN; EINA_MAIN_LOOP_CHECK_RETURN;
_efl_timer_util_delay(pd, add); _efl_loop_timer_util_delay(pd, add);
} }
EOLIAN static void EOLIAN static void
_efl_timer_reset(Eo *obj EINA_UNUSED, Efl_Timer_Data *timer) _efl_loop_timer_reset(Eo *obj EINA_UNUSED, Efl_Loop_Timer_Data *timer)
{ {
double now, add; double now, add;
EINA_MAIN_LOOP_CHECK_RETURN; EINA_MAIN_LOOP_CHECK_RETURN;
@ -293,11 +293,11 @@ _efl_timer_reset(Eo *obj EINA_UNUSED, Efl_Timer_Data *timer)
add = timer->pending; add = timer->pending;
else else
add = timer->at - now; add = timer->at - now;
_efl_timer_util_delay(timer, timer->in - add); _efl_loop_timer_util_delay(timer, timer->in - add);
} }
EOLIAN static void EOLIAN static void
_efl_timer_loop_reset(Eo *obj EINA_UNUSED, Efl_Timer_Data *timer) _efl_loop_timer_loop_reset(Eo *obj EINA_UNUSED, Efl_Loop_Timer_Data *timer)
{ {
double now, add; double now, add;
EINA_MAIN_LOOP_CHECK_RETURN; EINA_MAIN_LOOP_CHECK_RETURN;
@ -314,11 +314,11 @@ _efl_timer_loop_reset(Eo *obj EINA_UNUSED, Efl_Timer_Data *timer)
add = timer->pending; add = timer->pending;
else else
add = timer->at - now; add = timer->at - now;
_efl_timer_util_delay(timer, timer->in - add); _efl_loop_timer_util_delay(timer, timer->in - add);
} }
EOLIAN static double EOLIAN static double
_efl_timer_pending_get(Eo *obj EINA_UNUSED, Efl_Timer_Data *timer) _efl_loop_timer_pending_get(Eo *obj EINA_UNUSED, Efl_Loop_Timer_Data *timer)
{ {
double now; double now;
double ret = 0.0; double ret = 0.0;
@ -343,7 +343,7 @@ ecore_timer_freeze(Ecore_Timer *timer)
} }
EOLIAN static void EOLIAN static void
_efl_timer_eo_base_event_freeze(Eo *obj EINA_UNUSED, Efl_Timer_Data *timer) _efl_loop_timer_eo_base_event_freeze(Eo *obj EINA_UNUSED, Efl_Loop_Timer_Data *timer)
{ {
double now; double now;
@ -361,7 +361,7 @@ _efl_timer_eo_base_event_freeze(Eo *obj EINA_UNUSED, Efl_Timer_Data *timer)
timer->at = 0.0; timer->at = 0.0;
timer->frozen = 1; timer->frozen = 1;
_efl_timer_util_instanciate(timer); _efl_loop_timer_util_instanciate(timer);
} }
EAPI Eina_Bool EAPI Eina_Bool
@ -374,7 +374,7 @@ ecore_timer_freeze_get(Ecore_Timer *timer)
} }
EOLIAN static int EOLIAN static int
_efl_timer_eo_base_event_freeze_count_get(Eo *obj EINA_UNUSED, Efl_Timer_Data *timer) _efl_loop_timer_eo_base_event_freeze_count_get(Eo *obj EINA_UNUSED, Efl_Loop_Timer_Data *timer)
{ {
EINA_MAIN_LOOP_CHECK_RETURN_VAL(0); EINA_MAIN_LOOP_CHECK_RETURN_VAL(0);
@ -389,7 +389,7 @@ ecore_timer_thaw(Ecore_Timer *timer)
} }
EOLIAN static void EOLIAN static void
_efl_timer_eo_base_event_thaw(Eo *obj, Efl_Timer_Data *timer) _efl_loop_timer_eo_base_event_thaw(Eo *obj, Efl_Loop_Timer_Data *timer)
{ {
double now; double now;
@ -404,7 +404,7 @@ _efl_timer_eo_base_event_thaw(Eo *obj, Efl_Timer_Data *timer)
suspended = eina_inlist_remove(suspended, EINA_INLIST_GET(timer)); suspended = eina_inlist_remove(suspended, EINA_INLIST_GET(timer));
now = ecore_time_get(); now = ecore_time_get();
_efl_timer_set(timer, timer->pending + now, timer->in); _efl_loop_timer_set(timer, timer->pending + now, timer->in);
} }
EAPI char * EAPI char *
@ -414,9 +414,9 @@ ecore_timer_dump(void)
} }
static void static void
_efl_timer_util_instanciate(Efl_Timer_Data *timer) _efl_loop_timer_util_instanciate(Efl_Loop_Timer_Data *timer)
{ {
Efl_Timer_Data *t2; Efl_Loop_Timer_Data *t2;
Eina_Inlist *first; Eina_Inlist *first;
// Remove the timer from all possible pending list // Remove the timer from all possible pending list
@ -447,8 +447,8 @@ _efl_timer_util_instanciate(Efl_Timer_Data *timer)
} }
static void static void
_efl_timer_util_delay(Efl_Timer_Data *timer, _efl_loop_timer_util_delay(Efl_Loop_Timer_Data *timer,
double add) double add)
{ {
if (timer->frozen) if (timer->frozen)
{ {
@ -456,17 +456,17 @@ _efl_timer_util_delay(Efl_Timer_Data *timer,
return ; return ;
} }
_efl_timer_set(timer, timer->at + add, timer->in); _efl_loop_timer_set(timer, timer->at + add, timer->in);
} }
EOLIAN static void EOLIAN static void
_efl_timer_eo_base_destructor(Eo *obj, Efl_Timer_Data *pd) _efl_loop_timer_eo_base_destructor(Eo *obj, Efl_Loop_Timer_Data *pd)
{ {
Eina_Inlist *first; Eina_Inlist *first;
// Check if we are the current timer, if so move along // Check if we are the current timer, if so move along
if (timer_current == pd) if (timer_current == pd)
timer_current = (Efl_Timer_Data *)EINA_INLIST_GET(pd)->next; timer_current = (Efl_Loop_Timer_Data *)EINA_INLIST_GET(pd)->next;
// Remove the timer from all possible pending list // Remove the timer from all possible pending list
first = eina_inlist_first(EINA_INLIST_GET(pd)); first = eina_inlist_first(EINA_INLIST_GET(pd));
@ -479,9 +479,9 @@ _efl_timer_eo_base_destructor(Eo *obj, Efl_Timer_Data *pd)
} }
void void
_efl_timer_shutdown(void) _efl_loop_timer_shutdown(void)
{ {
Efl_Timer_Data *timer; Efl_Loop_Timer_Data *timer;
EINA_INLIST_FREE(timers, timer) EINA_INLIST_FREE(timers, timer)
eo_del(timer->object); eo_del(timer->object);
@ -493,9 +493,9 @@ _efl_timer_shutdown(void)
} }
void void
_efl_timer_enable_new(void) _efl_loop_timer_enable_new(void)
{ {
Efl_Timer_Data *timer; Efl_Loop_Timer_Data *timer;
if (!timers_added) return; if (!timers_added) return;
timers_added = 0; timers_added = 0;
@ -503,15 +503,15 @@ _efl_timer_enable_new(void)
} }
int int
_efl_timers_exists(void) _efl_loop_timers_exists(void)
{ {
return !!timers; return !!timers;
} }
static inline Ecore_Timer * static inline Ecore_Timer *
_efl_timer_first_get(void) _efl_loop_timer_first_get(void)
{ {
Efl_Timer_Data *timer; Efl_Loop_Timer_Data *timer;
EINA_INLIST_FOREACH(timers, timer) EINA_INLIST_FOREACH(timers, timer)
if (!timer->just_added) return timer->object; if (!timer->just_added) return timer->object;
@ -519,11 +519,11 @@ _efl_timer_first_get(void)
return NULL; return NULL;
} }
static inline Efl_Timer_Data * static inline Efl_Loop_Timer_Data *
_efl_timer_after_get(Efl_Timer_Data *base) _efl_loop_timer_after_get(Efl_Loop_Timer_Data *base)
{ {
Efl_Timer_Data *timer; Efl_Loop_Timer_Data *timer;
Efl_Timer_Data *valid_timer = base; Efl_Loop_Timer_Data *valid_timer = base;
double maxtime = base->at + precision; double maxtime = base->at + precision;
EINA_INLIST_FOREACH(EINA_INLIST_GET(base)->next, timer) EINA_INLIST_FOREACH(EINA_INLIST_GET(base)->next, timer)
@ -537,17 +537,17 @@ _efl_timer_after_get(Efl_Timer_Data *base)
} }
double double
_efl_timer_next_get(void) _efl_loop_timer_next_get(void)
{ {
Ecore_Timer *object; Ecore_Timer *object;
Efl_Timer_Data *first; Efl_Loop_Timer_Data *first;
double now; double now;
double in; double in;
object = _efl_timer_first_get(); object = _efl_loop_timer_first_get();
if (!object) return -1; if (!object) return -1;
first = _efl_timer_after_get(eo_data_scope_get(object, MY_CLASS)); first = _efl_loop_timer_after_get(eo_data_scope_get(object, MY_CLASS));
now = ecore_loop_time_get(); now = ecore_loop_time_get();
in = first->at - now; in = first->at - now;
@ -556,7 +556,7 @@ _efl_timer_next_get(void)
} }
static inline void static inline void
_efl_timer_reschedule(Efl_Timer_Data *timer, _efl_loop_timer_reschedule(Efl_Loop_Timer_Data *timer,
double when) double when)
{ {
if (timer->frozen) return; if (timer->frozen) return;
@ -573,25 +573,25 @@ _efl_timer_reschedule(Efl_Timer_Data *timer,
* really slow within the main loop. * really slow within the main loop.
*/ */
if ((timer->at + timer->in) < (when - 15.0)) if ((timer->at + timer->in) < (when - 15.0))
_efl_timer_set(timer, when + timer->in, timer->in); _efl_loop_timer_set(timer, when + timer->in, timer->in);
else else
_efl_timer_set(timer, timer->at + timer->in, timer->in); _efl_loop_timer_set(timer, timer->at + timer->in, timer->in);
} }
void void
_efl_timer_expired_timers_call(double when) _efl_loop_timer_expired_timers_call(double when)
{ {
/* call the first expired timer until no expired timers exist */ /* call the first expired timer until no expired timers exist */
while (_efl_timer_expired_call(when)) ; while (_efl_loop_timer_expired_call(when)) ;
} }
int int
_efl_timer_expired_call(double when) _efl_loop_timer_expired_call(double when)
{ {
if (!timers) return 0; if (!timers) return 0;
if (last_check > when) if (last_check > when)
{ {
Efl_Timer_Data *timer; Efl_Loop_Timer_Data *timer;
/* User set time backwards */ /* User set time backwards */
EINA_INLIST_FOREACH(timers, timer) timer->at -= (last_check - when); EINA_INLIST_FOREACH(timers, timer) timer->at -= (last_check - when);
} }
@ -600,20 +600,20 @@ _efl_timer_expired_call(double when)
if (!timer_current) if (!timer_current)
{ {
/* regular main loop, start from head */ /* regular main loop, start from head */
timer_current = (Efl_Timer_Data *)timers; timer_current = (Efl_Loop_Timer_Data *)timers;
} }
else else
{ {
/* recursive main loop, continue from where we were */ /* recursive main loop, continue from where we were */
Efl_Timer_Data *timer_old = timer_current; Efl_Loop_Timer_Data *timer_old = timer_current;
timer_current = (Efl_Timer_Data *)EINA_INLIST_GET(timer_current)->next; timer_current = (Efl_Loop_Timer_Data *)EINA_INLIST_GET(timer_current)->next;
_efl_timer_reschedule(timer_old, when); _efl_loop_timer_reschedule(timer_old, when);
} }
while (timer_current) while (timer_current)
{ {
Efl_Timer_Data *timer = timer_current; Efl_Loop_Timer_Data *timer = timer_current;
if (timer->at > when) if (timer->at > when)
{ {
@ -623,30 +623,30 @@ _efl_timer_expired_call(double when)
if (timer->just_added) if (timer->just_added)
{ {
timer_current = (Efl_Timer_Data *)EINA_INLIST_GET(timer_current)->next; timer_current = (Efl_Loop_Timer_Data *)EINA_INLIST_GET(timer_current)->next;
continue; continue;
} }
eo_ref(timer->object); eo_ref(timer->object);
eina_evlog("+timer", timer, 0.0, NULL); eina_evlog("+timer", timer, 0.0, NULL);
eo_event_callback_call(timer->object, EFL_TIMER_EVENT_TICK, NULL); eo_event_callback_call(timer->object, EFL_LOOP_TIMER_EVENT_TICK, NULL);
eina_evlog("-timer", timer, 0.0, NULL); eina_evlog("-timer", timer, 0.0, NULL);
/* may have changed in recursive main loops */ /* may have changed in recursive main loops */
/* this current timer can not die yet as we hold a reference on it */ /* this current timer can not die yet as we hold a reference on it */
if (timer_current) if (timer_current)
timer_current = (Efl_Timer_Data *)EINA_INLIST_GET(timer_current)->next; timer_current = (Efl_Loop_Timer_Data *)EINA_INLIST_GET(timer_current)->next;
_efl_timer_reschedule(timer, when); _efl_loop_timer_reschedule(timer, when);
eo_unref(timer->object); eo_unref(timer->object);
} }
return 0; return 0;
} }
static void static void
_efl_timer_set(Efl_Timer_Data *timer, _efl_loop_timer_set(Efl_Loop_Timer_Data *timer,
double at, double at,
double in) double in)
{ {
timers_added = 1; timers_added = 1;
timer->at = at; timer->at = at;
@ -656,7 +656,7 @@ _efl_timer_set(Efl_Timer_Data *timer,
timer->frozen = 0; timer->frozen = 0;
timer->pending = 0.0; timer->pending = 0.0;
_efl_timer_util_instanciate(timer); _efl_loop_timer_util_instanciate(timer);
} }
#include "efl_timer.eo.c" #include "efl_loop_timer.eo.c"

View File

@ -1,6 +1,6 @@
import ecore_types; import ecore_types;
class Efl.Timer (Efl.Loop_User) class Efl.Loop.Timer (Efl.Loop_User)
{ {
[[Timers are objects that will call a given callback at some point [[Timers are objects that will call a given callback at some point
in the future and repeat that tick at a given interval. in the future and repeat that tick at a given interval.