forked from enlightenment/efl
ecore: fix that timers are not called in the order they were registered.
Summary: Timers are not called in the order they were registered. Because when current timer is deleted, getting next timer is called twice. Test Plan: <error> Timer1 expired after 0.001 seconds. Timer3 expired after 0.001 seconds. Timer5 expired after 0.001 seconds. Timer7 expired after 0.001 seconds. Timer2 expired after 0.001 seconds. Timer6 expired after 0.001 seconds. Timer4 expired after 0.001 seconds. Timer8 expired after 0.001 seconds. <correct> Timer1 expired after 0.001 seconds. Timer2 expired after 0.001 seconds. Timer3 expired after 0.001 seconds. Timer4 expired after 0.001 seconds. Timer5 expired after 0.001 seconds. Timer6 expired after 0.001 seconds. Timer7 expired after 0.001 seconds. Timer8 expired after 0.001 seconds.| {F3268233} Reviewers: Hermet, Jaehyun_Cho, zmike, SanghyeonLee Reviewed By: zmike Subscribers: cedric, #committers, zmike Tags: #efl_tests Differential Revision: https://phab.enlightenment.org/D6700
This commit is contained in:
parent
9666f288ae
commit
a92274f811
|
@ -461,11 +461,20 @@ _efl_loop_timer_util_delay(Efl_Loop_Timer_Data *timer, double add)
|
|||
EOLIAN static void
|
||||
_efl_loop_timer_efl_object_parent_set(Eo *obj, Efl_Loop_Timer_Data *pd, Efl_Object *parent)
|
||||
{
|
||||
Eina_Inlist *first;
|
||||
|
||||
efl_parent_set(efl_super(obj, EFL_LOOP_TIMER_CLASS), parent);
|
||||
|
||||
if ((!pd->constructed) || (!pd->finalized)) return;
|
||||
|
||||
_efl_loop_timer_util_loop_clear(pd);
|
||||
// Remove the timer from all possible pending list
|
||||
first = eina_inlist_first(EINA_INLIST_GET(pd));
|
||||
if (first == pd->loop_data->timers)
|
||||
pd->loop_data->timers = eina_inlist_remove
|
||||
(pd->loop_data->timers, EINA_INLIST_GET(pd));
|
||||
else if (first == pd->loop_data->suspended)
|
||||
pd->loop_data->suspended = eina_inlist_remove
|
||||
(pd->loop_data->suspended, EINA_INLIST_GET(pd));
|
||||
|
||||
if (efl_invalidated_get(obj)) return;
|
||||
|
||||
|
@ -555,7 +564,7 @@ _efl_loop_timer_next_get(Eo *obj, Efl_Loop_Data *pd)
|
|||
static inline void
|
||||
_efl_loop_timer_reschedule(Efl_Loop_Timer_Data *timer, double when)
|
||||
{
|
||||
if (timer->frozen) return;
|
||||
if (timer->frozen || efl_invalidated_get(timer->object)) return;
|
||||
|
||||
if (timer->loop_data &&
|
||||
(EINA_INLIST_GET(timer)->next || EINA_INLIST_GET(timer)->prev))
|
||||
|
|
|
@ -252,10 +252,47 @@ EFL_START_TEST(ecore_test_ecore_main_loop_timer)
|
|||
}
|
||||
EFL_END_TEST
|
||||
|
||||
static int count = 0;
|
||||
|
||||
static Eina_Bool
|
||||
_timer_cb(void *data)
|
||||
{
|
||||
count++;
|
||||
int num = (intptr_t) data;
|
||||
fail_if (num != count, "Error timer is called out of order");
|
||||
if (count == 8) ecore_main_loop_quit();
|
||||
return ECORE_CALLBACK_CANCEL;
|
||||
}
|
||||
|
||||
EFL_START_TEST(ecore_test_timer_in_order)
|
||||
{
|
||||
Ecore_Timer *timer;
|
||||
timer = ecore_timer_add(0.001, _timer_cb, (void *) 1);
|
||||
fail_if(timer == NULL);
|
||||
timer = ecore_timer_add(0.001, _timer_cb, (void *) 2);
|
||||
fail_if(timer == NULL);
|
||||
timer = ecore_timer_add(0.001, _timer_cb, (void *) 3);
|
||||
fail_if(timer == NULL);
|
||||
timer = ecore_timer_add(0.001, _timer_cb, (void *) 4);
|
||||
fail_if(timer == NULL);
|
||||
timer = ecore_timer_add(0.001, _timer_cb, (void *) 5);
|
||||
fail_if(timer == NULL);
|
||||
timer = ecore_timer_add(0.001, _timer_cb, (void *) 6);
|
||||
fail_if(timer == NULL);
|
||||
timer = ecore_timer_add(0.001, _timer_cb, (void *) 7);
|
||||
fail_if(timer == NULL);
|
||||
timer = ecore_timer_add(0.001, _timer_cb, (void *) 8);
|
||||
fail_if(timer == NULL);
|
||||
|
||||
ecore_main_loop_begin();
|
||||
}
|
||||
EFL_END_TEST
|
||||
|
||||
void ecore_test_timer(TCase *tc)
|
||||
{
|
||||
tcase_add_test(tc, ecore_test_timers);
|
||||
tcase_add_test(tc, ecore_test_timer_inside_call);
|
||||
tcase_add_test(tc, ecore_test_timer_valid_callbackfunc);
|
||||
tcase_add_test(tc, ecore_test_ecore_main_loop_timer);
|
||||
tcase_add_test(tc, ecore_test_timer_in_order);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue