return in;
}
+static inline void
+_ecore_timer_reschedule(Ecore_Timer *timer, double when)
+{
+ if ((timer->delete_me) || (timer->frozen)) return;
+
+ timers = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer));
+
+ /* if the timer would have gone off more than 15 seconds ago,
+ * assume that the system hung and set the timer to go off
+ * timer->in from now. this handles system hangs, suspends
+ * and more, so ecore will only "replay" the timers while
+ * the system is suspended if it is suspended for less than
+ * 15 seconds (basically). this also handles if the process
+ * is stopped in a debugger or IO and other handling gets
+ * really slow within the main loop.
+ */
+ if ((timer->at + timer->in) < (when - 15.0))
+ _ecore_timer_set(timer, when + timer->in, timer->in, timer->func, timer->data);
+ else
+ _ecore_timer_set(timer, timer->at + timer->in, timer->in, timer->func, timer->data);
+}
+
int
_ecore_timer_call(double when)
{
else
{
/* recursive main loop, continue from where we were */
+ Ecore_Timer *timer_old = timer_current;
timer_current = (Ecore_Timer *)EINA_INLIST_GET(timer_current)->next;
+ _ecore_timer_reschedule(timer_old, when);
}
while (timer_current)
if (timer_current) /* may have changed in recursive main loops */
timer_current = (Ecore_Timer *)EINA_INLIST_GET(timer_current)->next;
- if ((!timer->delete_me) && (!timer->frozen))
- {
- timers = (Ecore_Timer *) eina_inlist_remove(EINA_INLIST_GET(timers), EINA_INLIST_GET(timer));
-
- /* if the timer would have gone off more than 15 seconds ago,
- * assume that the system hung and set the timer to go off
- * timer->in from now. this handles system hangs, suspends
- * and more, so ecore will only "replay" the timers while
- * the system is suspended if it is suspended for less than
- * 15 seconds (basically). this also handles if the process
- * is stopped in a debugger or IO and other handling gets
- * really slow within the main loop.
- */
- if ((timer->at + timer->in) < (when - 15.0))
- _ecore_timer_set(timer, when + timer->in, timer->in, timer->func, timer->data);
- else
- _ecore_timer_set(timer, timer->at + timer->in, timer->in, timer->func, timer->data);
- }
+ _ecore_timer_reschedule(timer, when);
}
return 0;
}
}
END_TEST
+static int _timer3(void *data)
+{
+ /* timer 3, do nothing */
+ return 0;
+}
+
+static int _timer2(void *data)
+{
+ /* timer 2, quit inner mainloop */
+ ecore_main_loop_quit();
+ return 0;
+}
+
+static int _timer1(void *data)
+{
+ /* timer 1, begin inner mainloop */
+ int *times = data;
+ (*times)++;
+
+ ecore_timer_add(0.3, _timer2, NULL);
+ ecore_timer_add(0.1, _timer3, NULL);
+ ecore_main_loop_begin();
+
+ ecore_main_loop_quit();
+
+ return 0;
+}
+
+START_TEST(ecore_test_ecore_main_loop_timer_inner)
+{
+ int times = 0;
+
+ ecore_init();
+ ecore_timer_add(1.0, _timer1, ×);
+
+ /* BEGIN: outer mainloop */
+ ecore_main_loop_begin();
+ /*END: outer mainloop */
+
+ fail_if(times != 1);
+}
+END_TEST
+
static int
_fd_handler_cb(void *data, Ecore_Fd_Handler *handler __UNUSED__)
{
tcase_add_test(tc, ecore_test_ecore_main_loop_timer);
tcase_add_test(tc, ecore_test_ecore_main_loop_fd_handler);
tcase_add_test(tc, ecore_test_ecore_main_loop_event);
+ tcase_add_test(tc, ecore_test_ecore_main_loop_timer_inner);
}