From 76b837002eaea56b5ecb174bffe284012084dc74 Mon Sep 17 00:00:00 2001 From: "Carsten Haitzler (Rasterman)" Date: Fri, 5 Jan 2018 15:01:02 +0900 Subject: [PATCH] efl loop - provide efl namespace versions of begin/end locks on mainloop add efl_main_loop_steal() and efl_main_loop_release() for new efl namespace versiosn of ecore_thread_main_loop_begin() and ecore_thread_main_loop_end(). --- src/lib/ecore/Ecore_Eo.h | 26 ++++++++++++++++++++++++++ src/lib/ecore/efl_loop.c | 12 ++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/lib/ecore/Ecore_Eo.h b/src/lib/ecore/Ecore_Eo.h index f121380f2b..d1da269f30 100644 --- a/src/lib/ecore/Ecore_Eo.h +++ b/src/lib/ecore/Ecore_Eo.h @@ -113,6 +113,32 @@ EAPI Eina_Promise *efl_loop_main_promise_new(Eina_Promise_Cancel_Cb cancel_cb, c /* We ue the factory pattern here, so you shouldn't call eo_add directly. */ EAPI Eo *efl_main_loop_get(void); +/** + * Sync with main loop and lock it out and begin a mainloop eo context + * + * @result The number of time ecore_thread_main_loop_begin() has been called + * in this thread. If not, it returns @c -1. + * + * This function suspends the main loop in a safe state and then lets + * use any EFL call you want after it returns as if it were running in the + * main loop (except it's called from the calling thread). Be careful since + * the main loop is blocked until you call efl_main_loop_release(). This is + * the only sane way to achieve pseudo thread safety. + * + * Note that until the main loop is blocked, this function stalls until the + * main loop comes to a safe point to be paused. + */ +EAPI int efl_main_loop_steal(void); + +/* Release a main loop lock taken by efl_main_loop_steal() + * + * @result The number of times efl_main_loop_release() needs to be called + * before the main loop is unlocked again. @c -1 will be returned if you + * are trying to unlock when no matching call to efl_main_loop_steal() was + * made by this thread. + */ +EAPI int efl_main_loop_release(void); + typedef struct _Efl_Future_Composite_Progress Efl_Future_All_Progress; struct _Efl_Future_Composite_Progress diff --git a/src/lib/ecore/efl_loop.c b/src/lib/ecore/efl_loop.c index cbd656e9b8..9a09a16c1d 100644 --- a/src/lib/ecore/efl_loop.c +++ b/src/lib/ecore/efl_loop.c @@ -66,6 +66,18 @@ efl_main_loop_get(void) return efl_loop_main_get(EFL_LOOP_CLASS); } +EAPI int +efl_main_loop_steal(void) +{ + return ecore_thread_main_loop_begin(); +} + +EAPI int +efl_main_loop_release(void) +{ + return ecore_thread_main_loop_end(); +} + EOLIAN static void _efl_loop_iterate(Eo *obj, Efl_Loop_Data *pd) {