summaryrefslogtreecommitdiff
path: root/src/lib/ecore
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2018-08-14 17:09:32 -0400
committerMike Blumenkrantz <zmike@samsung.com>2018-08-14 17:09:32 -0400
commit8e6d66450d8efa84697913b12a23beb747035606 (patch)
tree5f247bc3d0dec0d71533ea216c56d307493c124e /src/lib/ecore
parent55a2e77d60db910a433fade1c845402f45817fb6 (diff)
ecore/main: only update loop_time during loop iteration if the change is monotonic
Summary: in the case where the user has called loop_time_set with a value in the future, avoid setting the loop time to something that would potentially cause a callback to occur with a loop_time value before a previous occurrence of that callback @fix Reviewers: ManMower Reviewed By: ManMower Subscribers: ManMower, #reviewers, cedric, #committers Tags: #efl_main_loop Differential Revision: https://phab.enlightenment.org/D6764
Diffstat (limited to 'src/lib/ecore')
-rw-r--r--src/lib/ecore/ecore_main.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/src/lib/ecore/ecore_main.c b/src/lib/ecore/ecore_main.c
index 4b27e180a2..0ad01f502f 100644
--- a/src/lib/ecore/ecore_main.c
+++ b/src/lib/ecore/ecore_main.c
@@ -212,6 +212,14 @@ static gboolean _ecore_glib_idle_enterer_called;
212static gboolean ecore_fds_ready; 212static gboolean ecore_fds_ready;
213#endif 213#endif
214 214
215static inline void
216_update_loop_time(Efl_Loop_Data *pd)
217{
218 double loop_time = ecore_time_get();
219 if (loop_time > pd->loop_time)
220 pd->loop_time = loop_time;
221}
222
215#ifdef EFL_EXTRA_SANITY_CHECKS 223#ifdef EFL_EXTRA_SANITY_CHECKS
216static inline void 224static inline void
217_ecore_fd_valid(Eo *obj EINA_UNUSED, Efl_Loop_Data *pd EINA_UNUSED) 225_ecore_fd_valid(Eo *obj EINA_UNUSED, Efl_Loop_Data *pd EINA_UNUSED)
@@ -627,7 +635,7 @@ _ecore_main_gsource_prepare(GSource *source EINA_UNUSED,
627 635
628 if ((!ecore_idling) && (!_ecore_glib_idle_enterer_called)) 636 if ((!ecore_idling) && (!_ecore_glib_idle_enterer_called))
629 { 637 {
630 pd->loop_time = ecore_time_get(); 638 _update_loop_time(pd);
631 _efl_loop_timer_expired_timers_call(obj, pd, pd->loop_time); 639 _efl_loop_timer_expired_timers_call(obj, pd, pd->loop_time);
632 640
633 efl_event_callback_call(obj, EFL_LOOP_EVENT_IDLE_ENTER, NULL); 641 efl_event_callback_call(obj, EFL_LOOP_EVENT_IDLE_ENTER, NULL);
@@ -766,7 +774,7 @@ _ecore_main_gsource_dispatch(GSource *source EINA_UNUSED,
766 gboolean events_ready, timers_ready, idlers_ready; 774 gboolean events_ready, timers_ready, idlers_ready;
767 double next_time; 775 double next_time;
768 776
769 pd->loop_time = ecore_time_get(); 777 _update_loop_time(pd);
770 _efl_loop_timer_enable_new(obj, pd); 778 _efl_loop_timer_enable_new(obj, pd);
771 next_time = _efl_loop_timer_next_get(obj, pd); 779 next_time = _efl_loop_timer_next_get(obj, pd);
772 780
@@ -859,7 +867,7 @@ _ecore_main_loop_timer_run(uv_timer_t *timer EINA_UNUSED)
859 efl_event_callback_call(obj, EFL_LOOP_EVENT_IDLE_EXIT, NULL); 867 efl_event_callback_call(obj, EFL_LOOP_EVENT_IDLE_EXIT, NULL);
860 _ecore_animator_run_reset(); 868 _ecore_animator_run_reset();
861 } 869 }
862 pd->loop_time = ecore_time_get(); 870 _update_loop_time(pd);
863 _ecore_main_loop_uv_check(NULL); 871 _ecore_main_loop_uv_check(NULL);
864 _ecore_main_loop_uv_prepare(NULL); 872 _ecore_main_loop_uv_prepare(NULL);
865} 873}
@@ -1099,7 +1107,7 @@ _ecore_main_loop_iterate(Eo *obj, Efl_Loop_Data *pd)
1099 { 1107 {
1100#endif 1108#endif
1101#ifndef USE_G_MAIN_LOOP 1109#ifndef USE_G_MAIN_LOOP
1102 pd->loop_time = ecore_time_get(); 1110 _update_loop_time(pd);
1103 _ecore_main_loop_iterate_internal(obj, pd, 1); 1111 _ecore_main_loop_iterate_internal(obj, pd, 1);
1104#else 1112#else
1105 g_main_context_iteration(NULL, 0); 1113 g_main_context_iteration(NULL, 0);
@@ -1113,7 +1121,7 @@ _ecore_main_loop_iterate(Eo *obj, Efl_Loop_Data *pd)
1113 else 1121 else
1114 { 1122 {
1115#ifndef USE_G_MAIN_LOOP 1123#ifndef USE_G_MAIN_LOOP
1116 pd->loop_time = ecore_time_get(); 1124 _update_loop_time(pd);
1117 _ecore_main_loop_iterate_internal(obj, pd, 1); 1125 _ecore_main_loop_iterate_internal(obj, pd, 1);
1118#else 1126#else
1119 g_main_context_iteration(NULL, 0); 1127 g_main_context_iteration(NULL, 0);
@@ -1133,7 +1141,7 @@ _ecore_main_loop_iterate_may_block(Eo *obj, Efl_Loop_Data *pd, int may_block)
1133#ifndef USE_G_MAIN_LOOP 1141#ifndef USE_G_MAIN_LOOP
1134 in_main_loop++; 1142 in_main_loop++;
1135 pd->in_loop = in_main_loop; 1143 pd->in_loop = in_main_loop;
1136 pd->loop_time = ecore_time_get(); 1144 _update_loop_time(pd);
1137 _ecore_main_loop_iterate_internal(obj, pd, !may_block); 1145 _ecore_main_loop_iterate_internal(obj, pd, !may_block);
1138 in_main_loop--; 1146 in_main_loop--;
1139 pd->in_loop = in_main_loop; 1147 pd->in_loop = in_main_loop;
@@ -1152,7 +1160,7 @@ _ecore_main_loop_iterate_may_block(Eo *obj, Efl_Loop_Data *pd, int may_block)
1152 { 1160 {
1153#ifndef USE_G_MAIN_LOOP 1161#ifndef USE_G_MAIN_LOOP
1154 pd->in_loop++; 1162 pd->in_loop++;
1155 pd->loop_time = ecore_time_get(); 1163 _update_loop_time(pd);
1156 _ecore_main_loop_iterate_internal(obj, pd, !may_block); 1164 _ecore_main_loop_iterate_internal(obj, pd, !may_block);
1157 pd->in_loop--; 1165 pd->in_loop--;
1158 return pd->message_queue ? 1 : 0; 1166 return pd->message_queue ? 1 : 0;
@@ -1178,7 +1186,7 @@ _ecore_main_loop_begin(Eo *obj, Efl_Loop_Data *pd)
1178#ifndef USE_G_MAIN_LOOP 1186#ifndef USE_G_MAIN_LOOP
1179 in_main_loop++; 1187 in_main_loop++;
1180 pd->in_loop = in_main_loop; 1188 pd->in_loop = in_main_loop;
1181 pd->loop_time = ecore_time_get(); 1189 _update_loop_time(pd);
1182 while (!pd->do_quit) 1190 while (!pd->do_quit)
1183 _ecore_main_loop_iterate_internal(obj, pd, 0); 1191 _ecore_main_loop_iterate_internal(obj, pd, 0);
1184 pd->do_quit = 0; 1192 pd->do_quit = 0;
@@ -1200,7 +1208,7 @@ _ecore_main_loop_begin(Eo *obj, Efl_Loop_Data *pd)
1200 DBG("uv_run"); 1208 DBG("uv_run");
1201 in_main_loop++; 1209 in_main_loop++;
1202 pd->in_loop = in_main_loop; 1210 pd->in_loop = in_main_loop;
1203 pd->loop_time = ecore_time_get(); 1211 _update_loop_time(pd);
1204 while (!pd->do_quit) 1212 while (!pd->do_quit)
1205 _dl_uv_run(_dl_uv_default_loop(), UV_RUN_DEFAULT); 1213 _dl_uv_run(_dl_uv_default_loop(), UV_RUN_DEFAULT);
1206 in_main_loop--; 1214 in_main_loop--;
@@ -1214,7 +1222,7 @@ _ecore_main_loop_begin(Eo *obj, Efl_Loop_Data *pd)
1214 { 1222 {
1215#ifndef USE_G_MAIN_LOOP 1223#ifndef USE_G_MAIN_LOOP
1216 pd->in_loop++; 1224 pd->in_loop++;
1217 pd->loop_time = ecore_time_get(); 1225 _update_loop_time(pd);
1218 while (!pd->do_quit) 1226 while (!pd->do_quit)
1219 _ecore_main_loop_iterate_internal(obj, pd, 0); 1227 _ecore_main_loop_iterate_internal(obj, pd, 0);
1220 pd->do_quit = 0; 1228 pd->do_quit = 0;
@@ -1839,7 +1847,7 @@ _ecore_main_select(Eo *obj, Efl_Loop_Data *pd, double timeout)
1839 eina_evlog("!WAKE", NULL, 0.0, NULL); 1847 eina_evlog("!WAKE", NULL, 0.0, NULL);
1840 eina_evlog(">RUN", NULL, 0.0, NULL); 1848 eina_evlog(">RUN", NULL, 0.0, NULL);
1841 1849
1842 pd->loop_time = ecore_time_get(); 1850 _update_loop_time(pd);
1843 if (ret < 0) 1851 if (ret < 0)
1844 { 1852 {
1845#ifndef _WIN32 1853#ifndef _WIN32
@@ -2212,14 +2220,14 @@ _ecore_main_loop_uv_prepare(uv_prepare_t *handle EINA_UNUSED)
2212 _ecore_main_uv_idling = EINA_FALSE; 2220 _ecore_main_uv_idling = EINA_FALSE;
2213 } 2221 }
2214 t = -1; 2222 t = -1;
2215 pd->loop_time = ecore_time_get(); 2223 _update_loop_time(pd);
2216 _efl_loop_timer_enable_new(obj, pd); 2224 _efl_loop_timer_enable_new(obj, pd);
2217 goto done; 2225 goto done;
2218 } 2226 }
2219 2227
2220 assert(!pd->fd_handlers_to_call); 2228 assert(!pd->fd_handlers_to_call);
2221 2229
2222 pd->loop_time = ecore_time_get(); 2230 _update_loop_time(pd);
2223 _efl_loop_timer_enable_new(obj, pd); 2231 _efl_loop_timer_enable_new(obj, pd);
2224 if (_efl_loop_timers_exists(obj, pd) || (t >= 0)) 2232 if (_efl_loop_timers_exists(obj, pd) || (t >= 0))
2225 { 2233 {
@@ -2257,7 +2265,7 @@ static int
2257_ecore_main_loop_spin_core(Eo *obj, Efl_Loop_Data *pd) 2265_ecore_main_loop_spin_core(Eo *obj, Efl_Loop_Data *pd)
2258{ 2266{
2259 // as we are spinning we need to update loop time per spin 2267 // as we are spinning we need to update loop time per spin
2260 pd->loop_time = ecore_time_get(); 2268 _update_loop_time(pd);
2261 // call all idlers 2269 // call all idlers
2262 _ecore_main_idler_all_call(obj); 2270 _ecore_main_idler_all_call(obj);
2263 // which returns false if no more idelrs exist 2271 // which returns false if no more idelrs exist