summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHosang Kim <hosang12.kim@samsung.com>2018-08-02 09:14:15 -0400
committerMike Blumenkrantz <zmike@samsung.com>2018-08-02 09:14:15 -0400
commita92274f81184cd06b398a0930110f2a4bee49e76 (patch)
tree3c56cc868338410adb8864d83431220f933e8250 /src
parent9666f288ae606f181f676ad1768864d830d29ee3 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/lib/ecore/ecore_timer.c13
-rw-r--r--src/tests/ecore/ecore_test_timer.c37
2 files changed, 48 insertions, 2 deletions
diff --git a/src/lib/ecore/ecore_timer.c b/src/lib/ecore/ecore_timer.c
index 1ebce1f3df..776848875c 100644
--- a/src/lib/ecore/ecore_timer.c
+++ b/src/lib/ecore/ecore_timer.c
@@ -461,11 +461,20 @@ _efl_loop_timer_util_delay(Efl_Loop_Timer_Data *timer, double add)
461EOLIAN static void 461EOLIAN static void
462_efl_loop_timer_efl_object_parent_set(Eo *obj, Efl_Loop_Timer_Data *pd, Efl_Object *parent) 462_efl_loop_timer_efl_object_parent_set(Eo *obj, Efl_Loop_Timer_Data *pd, Efl_Object *parent)
463{ 463{
464 Eina_Inlist *first;
465
464 efl_parent_set(efl_super(obj, EFL_LOOP_TIMER_CLASS), parent); 466 efl_parent_set(efl_super(obj, EFL_LOOP_TIMER_CLASS), parent);
465 467
466 if ((!pd->constructed) || (!pd->finalized)) return; 468 if ((!pd->constructed) || (!pd->finalized)) return;
467 469
468 _efl_loop_timer_util_loop_clear(pd); 470 // Remove the timer from all possible pending list
471 first = eina_inlist_first(EINA_INLIST_GET(pd));
472 if (first == pd->loop_data->timers)
473 pd->loop_data->timers = eina_inlist_remove
474 (pd->loop_data->timers, EINA_INLIST_GET(pd));
475 else if (first == pd->loop_data->suspended)
476 pd->loop_data->suspended = eina_inlist_remove
477 (pd->loop_data->suspended, EINA_INLIST_GET(pd));
469 478
470 if (efl_invalidated_get(obj)) return; 479 if (efl_invalidated_get(obj)) return;
471 480
@@ -555,7 +564,7 @@ _efl_loop_timer_next_get(Eo *obj, Efl_Loop_Data *pd)
555static inline void 564static inline void
556_efl_loop_timer_reschedule(Efl_Loop_Timer_Data *timer, double when) 565_efl_loop_timer_reschedule(Efl_Loop_Timer_Data *timer, double when)
557{ 566{
558 if (timer->frozen) return; 567 if (timer->frozen || efl_invalidated_get(timer->object)) return;
559 568
560 if (timer->loop_data && 569 if (timer->loop_data &&
561 (EINA_INLIST_GET(timer)->next || EINA_INLIST_GET(timer)->prev)) 570 (EINA_INLIST_GET(timer)->next || EINA_INLIST_GET(timer)->prev))
diff --git a/src/tests/ecore/ecore_test_timer.c b/src/tests/ecore/ecore_test_timer.c
index 7b41b8bc1b..222c4151c5 100644
--- a/src/tests/ecore/ecore_test_timer.c
+++ b/src/tests/ecore/ecore_test_timer.c
@@ -252,10 +252,47 @@ EFL_START_TEST(ecore_test_ecore_main_loop_timer)
252} 252}
253EFL_END_TEST 253EFL_END_TEST
254 254
255static int count = 0;
256
257static Eina_Bool
258_timer_cb(void *data)
259{
260 count++;
261 int num = (intptr_t) data;
262 fail_if (num != count, "Error timer is called out of order");
263 if (count == 8) ecore_main_loop_quit();
264 return ECORE_CALLBACK_CANCEL;
265}
266
267EFL_START_TEST(ecore_test_timer_in_order)
268{
269 Ecore_Timer *timer;
270 timer = ecore_timer_add(0.001, _timer_cb, (void *) 1);
271 fail_if(timer == NULL);
272 timer = ecore_timer_add(0.001, _timer_cb, (void *) 2);
273 fail_if(timer == NULL);
274 timer = ecore_timer_add(0.001, _timer_cb, (void *) 3);
275 fail_if(timer == NULL);
276 timer = ecore_timer_add(0.001, _timer_cb, (void *) 4);
277 fail_if(timer == NULL);
278 timer = ecore_timer_add(0.001, _timer_cb, (void *) 5);
279 fail_if(timer == NULL);
280 timer = ecore_timer_add(0.001, _timer_cb, (void *) 6);
281 fail_if(timer == NULL);
282 timer = ecore_timer_add(0.001, _timer_cb, (void *) 7);
283 fail_if(timer == NULL);
284 timer = ecore_timer_add(0.001, _timer_cb, (void *) 8);
285 fail_if(timer == NULL);
286
287 ecore_main_loop_begin();
288}
289EFL_END_TEST
290
255void ecore_test_timer(TCase *tc) 291void ecore_test_timer(TCase *tc)
256{ 292{
257 tcase_add_test(tc, ecore_test_timers); 293 tcase_add_test(tc, ecore_test_timers);
258 tcase_add_test(tc, ecore_test_timer_inside_call); 294 tcase_add_test(tc, ecore_test_timer_inside_call);
259 tcase_add_test(tc, ecore_test_timer_valid_callbackfunc); 295 tcase_add_test(tc, ecore_test_timer_valid_callbackfunc);
260 tcase_add_test(tc, ecore_test_ecore_main_loop_timer); 296 tcase_add_test(tc, ecore_test_ecore_main_loop_timer);
297 tcase_add_test(tc, ecore_test_timer_in_order);
261} 298}