summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-12-21 16:34:05 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-12-21 17:55:03 +0900
commit04a01c13af3b212224b94097ed39f3cc6ad1fd31 (patch)
tree99e800fe1bf3b765b7867c9f58251ba751e0ed0d
parent481853e1edbba2536f0189335f564e6133644f84 (diff)
ecore/efl loop. remove internal ecore_timer legacy api usage for eflloop
efl.loop was still using legacy ecore_timer_* calls inside. of course this is a big no-no if we are to allow multiple loops, so clean this up and convert them to efl.loop.timers.
-rw-r--r--src/lib/ecore/ecore.c24
-rw-r--r--src/lib/ecore/ecore_exe_posix.c11
-rw-r--r--src/lib/ecore/ecore_private.h11
-rw-r--r--src/lib/ecore/ecore_signal.c38
-rw-r--r--src/lib/ecore/efl_loop.c27
5 files changed, 60 insertions, 51 deletions
diff --git a/src/lib/ecore/ecore.c b/src/lib/ecore/ecore.c
index 0c19d4b482..26a7481d49 100644
--- a/src/lib/ecore/ecore.c
+++ b/src/lib/ecore/ecore.c
@@ -87,10 +87,6 @@ struct _Ecore_Safe_Call
87 Eina_Bool suspend : 1; 87 Eina_Bool suspend : 1;
88}; 88};
89 89
90#ifdef HAVE_SYSTEMD
91static Eina_Bool _systemd_watchdog_cb(void *data);
92#endif
93
94static void _ecore_main_loop_thread_safe_call(Ecore_Safe_Call *order); 90static void _ecore_main_loop_thread_safe_call(Ecore_Safe_Call *order);
95static void _thread_safe_cleanup(void *data); 91static void _thread_safe_cleanup(void *data);
96static void _thread_callback(void *data, 92static void _thread_callback(void *data,
@@ -116,7 +112,9 @@ static Ecore_Power_State _ecore_power_state = ECORE_POWER_STATE_MAINS;
116static Ecore_Memory_State _ecore_memory_state = ECORE_MEMORY_STATE_NORMAL; 112static Ecore_Memory_State _ecore_memory_state = ECORE_MEMORY_STATE_NORMAL;
117 113
118#ifdef HAVE_SYSTEMD 114#ifdef HAVE_SYSTEMD
119static Ecore_Timer *_systemd_watchdog = NULL; 115static void _systemd_watchdog_cb(void *data, const Efl_Event *event);
116
117static Efl_Loop_Timer *_systemd_watchdog = NULL;
120#endif 118#endif
121 119
122static Efl_Vpath *vpath = NULL; 120static Efl_Vpath *vpath = NULL;
@@ -324,12 +322,17 @@ ecore_init(void)
324 322
325 sec = ((double) atoi(getenv("WATCHDOG_USEC"))) / 1000 / 1000; 323 sec = ((double) atoi(getenv("WATCHDOG_USEC"))) / 1000 / 1000;
326 324
327 _systemd_watchdog = ecore_timer_add(sec / 2, _systemd_watchdog_cb, NULL); 325 _systemd_watchdog =
326 efl_add(EFL_LOOP_TIMER_CLASS, ecore_main_loop_get(),
327 efl_loop_timer_interval_set(efl_added, sec / 2),
328 efl_event_callback_add(efl_added,
329 EFL_LOOP_TIMER_EVENT_TICK,
330 _systemd_watchdog_cb, NULL));
328 unsetenv("WATCHDOG_USEC"); 331 unsetenv("WATCHDOG_USEC");
329 332
330 INF("Setup systemd watchdog to : %f", sec); 333 INF("Setup systemd watchdog to : %f", sec);
331 334
332 _systemd_watchdog_cb(NULL); 335 _systemd_watchdog_cb(NULL, NULL);
333 } 336 }
334#endif 337#endif
335 338
@@ -399,7 +402,7 @@ ecore_shutdown(void)
399#ifdef HAVE_SYSTEMD 402#ifdef HAVE_SYSTEMD
400 if (_systemd_watchdog) 403 if (_systemd_watchdog)
401 { 404 {
402 ecore_timer_del(_systemd_watchdog); 405 efl_del(_systemd_watchdog);
403 _systemd_watchdog = NULL; 406 _systemd_watchdog = NULL;
404 } 407 }
405#endif 408#endif
@@ -959,11 +962,10 @@ _ecore_fps_debug_runtime_add(double t)
959} 962}
960 963
961#ifdef HAVE_SYSTEMD 964#ifdef HAVE_SYSTEMD
962static Eina_Bool 965static void
963_systemd_watchdog_cb(EINA_UNUSED void *data) 966_systemd_watchdog_cb(void *data EINA_UNUSED, const Efl_Event *event EINA_UNUSED)
964{ 967{
965 sd_notify(0, "WATCHDOG=1"); 968 sd_notify(0, "WATCHDOG=1");
966 return ECORE_CALLBACK_RENEW;
967} 969}
968#endif 970#endif
969 971
diff --git a/src/lib/ecore/ecore_exe_posix.c b/src/lib/ecore/ecore_exe_posix.c
index 21d8861ef2..2d8fa98983 100644
--- a/src/lib/ecore/ecore_exe_posix.c
+++ b/src/lib/ecore/ecore_exe_posix.c
@@ -889,7 +889,7 @@ _impl_ecore_exe_hup(Ecore_Exe *obj EINA_UNUSED, Ecore_Exe_Data *exe)
889} 889}
890 890
891static void 891static void
892_ecore_exe_make_sure_its_dead(void *data, const Efl_Event *event EINA_UNUSED) 892_ecore_exe_make_sure_its_dead(void *data, const Efl_Event *event)
893{ 893{
894 Eo *exe_obj = data; 894 Eo *exe_obj = data;
895 Ecore_Exe_Data *exe = efl_data_scope_get(exe_obj, MY_CLASS); 895 Ecore_Exe_Data *exe = efl_data_scope_get(exe_obj, MY_CLASS);
@@ -907,10 +907,11 @@ _ecore_exe_make_sure_its_dead(void *data, const Efl_Event *event EINA_UNUSED)
907 efl_loop_timer_interval_set(efl_added, 10.0)); 907 efl_loop_timer_interval_set(efl_added, 10.0));
908 kill(exe->pid, SIGKILL); 908 kill(exe->pid, SIGKILL);
909 } 909 }
910 efl_del(event->object);
910} 911}
911 912
912static void 913static void
913_ecore_exe_make_sure_its_really_dead(void *data, const Efl_Event *event EINA_UNUSED) 914_ecore_exe_make_sure_its_really_dead(void *data, const Efl_Event *event)
914{ 915{
915 Eo *exe_obj = data; 916 Eo *exe_obj = data;
916 Ecore_Exe_Data *exe = efl_data_scope_get(exe_obj, MY_CLASS); 917 Ecore_Exe_Data *exe = efl_data_scope_get(exe_obj, MY_CLASS);
@@ -923,9 +924,10 @@ _ecore_exe_make_sure_its_really_dead(void *data, const Efl_Event *event EINA_UNU
923 INF("PID %d is not really dead.", exe->pid); 924 INF("PID %d is not really dead.", exe->pid);
924 exe->doomsday_clock = NULL; 925 exe->doomsday_clock = NULL;
925 } 926 }
927 efl_del(event->object);
926} 928}
927 929
928Ecore_Timer * 930Efl_Loop_Timer *
929_ecore_exe_doomsday_clock_get(Ecore_Exe *obj) 931_ecore_exe_doomsday_clock_get(Ecore_Exe *obj)
930{ 932{
931 Ecore_Exe_Data *exe = efl_data_scope_get(obj, MY_CLASS); 933 Ecore_Exe_Data *exe = efl_data_scope_get(obj, MY_CLASS);
@@ -934,8 +936,7 @@ _ecore_exe_doomsday_clock_get(Ecore_Exe *obj)
934} 936}
935 937
936void 938void
937_ecore_exe_doomsday_clock_set(Ecore_Exe *obj, 939_ecore_exe_doomsday_clock_set(Ecore_Exe *obj, Efl_Loop_Timer *dc)
938 Ecore_Timer *dc)
939{ 940{
940 Ecore_Exe_Data *exe = efl_data_scope_get(obj, MY_CLASS); 941 Ecore_Exe_Data *exe = efl_data_scope_get(obj, MY_CLASS);
941 if (!exe) return; 942 if (!exe) return;
diff --git a/src/lib/ecore/ecore_private.h b/src/lib/ecore/ecore_private.h
index 2d65477bb7..9c0d5f3dc7 100644
--- a/src/lib/ecore/ecore_private.h
+++ b/src/lib/ecore/ecore_private.h
@@ -108,9 +108,9 @@ struct _Efl_Loop_Data
108 double loop_time; 108 double loop_time;
109 Eina_Hash *providers; 109 Eina_Hash *providers;
110 110
111 Ecore_Timer *poll_high; 111 Efl_Loop_Timer *poll_high;
112 Ecore_Timer *poll_medium; 112 Efl_Loop_Timer *poll_medium;
113 Ecore_Timer *poll_low; 113 Efl_Loop_Timer *poll_low;
114 114
115 Eina_List *exes; // only used in main loop (for now?) 115 Eina_List *exes; // only used in main loop (for now?)
116 116
@@ -261,9 +261,8 @@ Ecore_Event *_ecore_event_add(int type,
261 void *data); 261 void *data);
262void _ecore_event_call(void); 262void _ecore_event_call(void);
263 263
264Ecore_Timer *_ecore_exe_doomsday_clock_get(Ecore_Exe *exe); 264Efl_Loop_Timer *_ecore_exe_doomsday_clock_get(Ecore_Exe *exe);
265void _ecore_exe_doomsday_clock_set(Ecore_Exe *exe, 265void _ecore_exe_doomsday_clock_set(Ecore_Exe *exe, Efl_Loop_Timer *dc);
266 Ecore_Timer *dc);
267 266
268void *_ecore_event_signal_user_new(void); 267void *_ecore_event_signal_user_new(void);
269void *_ecore_event_signal_hup_new(void); 268void *_ecore_event_signal_hup_new(void);
diff --git a/src/lib/ecore/ecore_signal.c b/src/lib/ecore/ecore_signal.c
index 450342a2c7..3d743a21cd 100644
--- a/src/lib/ecore/ecore_signal.c
+++ b/src/lib/ecore/ecore_signal.c
@@ -52,7 +52,7 @@ static void _ecore_signal_callback_sigpwr(int sig,
52 void *foo); 52 void *foo);
53#endif 53#endif
54 54
55static Eina_Bool _ecore_signal_exe_exit_delay(void *data); 55static void _ecore_signal_exe_exit_delay(void *data, const Efl_Event *event);
56 56
57//#define MAXSIGQ 256 // 32k 57//#define MAXSIGQ 256 // 32k
58#define MAXSIGQ 64 // 8k 58#define MAXSIGQ 64 // 8k
@@ -162,7 +162,7 @@ _ecore_signal_generic_free(void *data EINA_UNUSED, void *event)
162} 162}
163 163
164void 164void
165_ecore_signal_call(Eo *obj EINA_UNUSED, Efl_Loop_Data *pd EINA_UNUSED) 165_ecore_signal_call(Eo *obj, Efl_Loop_Data *pd EINA_UNUSED)
166{ 166{
167 volatile sig_atomic_t n; 167 volatile sig_atomic_t n;
168 sigset_t oldset, newset; 168 sigset_t oldset, newset;
@@ -258,12 +258,15 @@ _ecore_signal_call(Eo *obj EINA_UNUSED, Efl_Loop_Data *pd EINA_UNUSED)
258 * check to see for Last Words, and only delay if there are any. 258 * check to see for Last Words, and only delay if there are any.
259 * This has it's own set of problems. 259 * This has it's own set of problems.
260 */ 260 */
261 Ecore_Timer *doomsday_clock; 261 Efl_Loop_Timer *doomsday_clock =
262 262 _ecore_exe_doomsday_clock_get(e->exe);
263 doomsday_clock = _ecore_exe_doomsday_clock_get(e->exe); 263 efl_del(doomsday_clock);
264 IF_FN_DEL(ecore_timer_del, doomsday_clock); 264 doomsday_clock =
265 doomsday_clock = ecore_timer_add 265 efl_add(EFL_LOOP_TIMER_CLASS, obj,
266 (0.1, _ecore_signal_exe_exit_delay, e); 266 efl_loop_timer_interval_set(efl_added, 0.1),
267 efl_event_callback_add
268 (efl_added, EFL_LOOP_TIMER_EVENT_TICK,
269 _ecore_signal_exe_exit_delay, e));
267 _ecore_exe_doomsday_clock_set(e->exe, doomsday_clock); 270 _ecore_exe_doomsday_clock_set(e->exe, doomsday_clock);
268 } 271 }
269 else 272 else
@@ -601,18 +604,15 @@ _ecore_signal_callback_sigpwr(int sig EINA_UNUSED,
601 604
602#endif 605#endif
603 606
604static Eina_Bool 607static void
605_ecore_signal_exe_exit_delay(void *data) 608_ecore_signal_exe_exit_delay(void *data, const Efl_Event *event)
606{ 609{
607 Ecore_Exe_Event_Del *e; 610 Ecore_Exe_Event_Del *e = data;
608 611
609 e = data; 612 if (!e) return;
610 if (e) 613 _ecore_exe_doomsday_clock_set(e->exe, NULL);
611 { 614 ecore_event_add(ECORE_EXE_EVENT_DEL, e,
612 _ecore_exe_doomsday_clock_set(e->exe, NULL); 615 _ecore_exe_event_del_free, NULL);
613 ecore_event_add(ECORE_EXE_EVENT_DEL, e, 616 efl_del(event->object);
614 _ecore_exe_event_del_free, NULL);
615 }
616 return ECORE_CALLBACK_CANCEL;
617} 617}
618 618
diff --git a/src/lib/ecore/efl_loop.c b/src/lib/ecore/efl_loop.c
index 79509703b2..6cf133f981 100644
--- a/src/lib/ecore/efl_loop.c
+++ b/src/lib/ecore/efl_loop.c
@@ -19,7 +19,7 @@ typedef struct _Efl_Internal_Promise Efl_Internal_Promise;
19struct _Efl_Loop_Promise_Simple_Data 19struct _Efl_Loop_Promise_Simple_Data
20{ 20{
21 union { 21 union {
22 Ecore_Timer *timer; 22 Efl_Loop_Timer *timer;
23 Ecore_Idler *idler; 23 Ecore_Idler *idler;
24 }; 24 };
25 Eina_Promise *promise; 25 Eina_Promise *promise;
@@ -265,7 +265,7 @@ _check_event_catcher_del(void *data, const Efl_Event *event)
265 --pd->pollers.high; 265 --pd->pollers.high;
266 if (!pd->pollers.high) 266 if (!pd->pollers.high)
267 { 267 {
268 ecore_timer_del(pd->poll_high); 268 efl_del(pd->poll_high);
269 pd->poll_high = NULL; 269 pd->poll_high = NULL;
270 } 270 }
271 } 271 }
@@ -274,7 +274,7 @@ _check_event_catcher_del(void *data, const Efl_Event *event)
274 --pd->pollers.medium; 274 --pd->pollers.medium;
275 if (!pd->pollers.medium) 275 if (!pd->pollers.medium)
276 { 276 {
277 ecore_timer_del(pd->poll_medium); 277 efl_del(pd->poll_medium);
278 pd->poll_medium = NULL; 278 pd->poll_medium = NULL;
279 } 279 }
280 } 280 }
@@ -283,7 +283,7 @@ _check_event_catcher_del(void *data, const Efl_Event *event)
283 --pd->pollers.low; 283 --pd->pollers.low;
284 if (!pd->pollers.low) 284 if (!pd->pollers.low)
285 { 285 {
286 ecore_timer_del(pd->poll_low); 286 efl_del(pd->poll_low);
287 pd->poll_low = NULL; 287 pd->poll_low = NULL;
288 } 288 }
289 } 289 }
@@ -504,21 +504,24 @@ static void
504_efl_loop_timeout_cancel(void *data, const Eina_Promise *dead_ptr EINA_UNUSED) 504_efl_loop_timeout_cancel(void *data, const Eina_Promise *dead_ptr EINA_UNUSED)
505{ 505{
506 Efl_Loop_Promise_Simple_Data *d = data; 506 Efl_Loop_Promise_Simple_Data *d = data;
507 ecore_timer_del(d->timer); 507 efl_del(d->timer);
508 d->timer = NULL;
508 efl_loop_promise_simple_data_mp_free(d); 509 efl_loop_promise_simple_data_mp_free(d);
509} 510}
510 511
511static Eina_Bool 512static void
512_efl_loop_timeout_done(void *data) 513_efl_loop_timeout_done(void *data, const Efl_Event *event)
513{ 514{
514 Efl_Loop_Promise_Simple_Data *d = data; 515 Efl_Loop_Promise_Simple_Data *d = data;
516
515 eina_promise_resolve(d->promise, EINA_VALUE_EMPTY); 517 eina_promise_resolve(d->promise, EINA_VALUE_EMPTY);
518 d->timer = NULL;
516 efl_loop_promise_simple_data_mp_free(d); 519 efl_loop_promise_simple_data_mp_free(d);
517 return EINA_FALSE; 520 efl_del(event->object);
518} 521}
519 522
520static Eina_Future * 523static Eina_Future *
521_efl_loop_timeout(Eo *obj, Efl_Loop_Data *pd EINA_UNUSED, double time) 524_efl_loop_timeout(Eo *obj, Efl_Loop_Data *pd EINA_UNUSED, double tim)
522{ 525{
523 Efl_Loop_Promise_Simple_Data *d; 526 Efl_Loop_Promise_Simple_Data *d;
524 Eina_Promise *p; 527 Eina_Promise *p;
@@ -526,7 +529,11 @@ _efl_loop_timeout(Eo *obj, Efl_Loop_Data *pd EINA_UNUSED, double time)
526 d = efl_loop_promise_simple_data_calloc(1); 529 d = efl_loop_promise_simple_data_calloc(1);
527 EINA_SAFETY_ON_NULL_RETURN_VAL(d, NULL); 530 EINA_SAFETY_ON_NULL_RETURN_VAL(d, NULL);
528 531
529 d->timer = ecore_timer_add(time, _efl_loop_timeout_done, d); 532 d->timer = efl_add(EFL_LOOP_TIMER_CLASS, obj,
533 efl_loop_timer_interval_set(efl_added, tim),
534 efl_event_callback_add(efl_added,
535 EFL_LOOP_TIMER_EVENT_TICK,
536 _efl_loop_timeout_done, d));
530 EINA_SAFETY_ON_NULL_GOTO(d->timer, timer_error); 537 EINA_SAFETY_ON_NULL_GOTO(d->timer, timer_error);
531 538
532 p = eina_promise_new(efl_loop_future_scheduler_get(obj), 539 p = eina_promise_new(efl_loop_future_scheduler_get(obj),