Add timer for callbacks in main loop 65/291165/1
authorSuyeon Hwang <stom.hwang@samsung.com>
Mon, 10 Apr 2023 09:06:35 +0000 (18:06 +0900)
committerTizen AI <ai.tzn.sec@samsung.com>
Tue, 11 Apr 2023 05:19:43 +0000 (14:19 +0900)
- Issue:
When the app calls setting API in sub-thread, the changed callback can
not be invoked properly.

- Solution:
Most ecore API function properly works in main loop, and
ecore_timer_add() is also a functions of this kind. Therefore, if the app
calls setting API function in sub-thread, the changed event callbacks
can not be invoked. To solve this issue, this patch changes the ecore
timer registration logic. Through this patch, every timer will be added
in main loop by ecore_main_loop_thread_safe_call_sync().

Change-Id: I8ce976cf2b86b1c2a309ea887f17f1641b9e3f01
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
common/vc_config_mgr.cpp

index 6977544..d45d930 100644 (file)
@@ -142,8 +142,12 @@ static void notify_engine_changed(const char *engine_appid)
                return;
        }
 
-       delete_engine_changed_event_invoker();
-       g_engine_changed_event_invoker = ecore_timer_add(0.0, notify_engine_changed_event_by_invoker, static_cast<void *>(param));
+       ecore_main_loop_thread_safe_call_sync([](void *data) -> void * {
+               SLOG(LOG_INFO, vc_config_tag(), "[INFO] Register timer for engine changed event");
+               delete_engine_changed_event_invoker();
+               g_engine_changed_event_invoker = ecore_timer_add(0.0, notify_engine_changed_event_by_invoker, data);
+               return nullptr;
+       }, static_cast<void *>(param));
 }
 
 static inline void release_language_changed_cb_params(language_changed_cb_parameters_s *params)
@@ -215,8 +219,12 @@ static void notify_language_changed(const char* before_lang, const char* current
        params->before_lang = strdup(before_lang);
        params->current_lang = strdup(current_lang);
 
-       delete_language_changed_event_invoker();
-       g_language_changed_event_invoker = ecore_timer_add(0.0, notify_language_changed_event_by_invoker, static_cast<void *>(params));
+       ecore_main_loop_thread_safe_call_sync([](void *data) -> void * {
+               SLOG(LOG_INFO, vc_config_tag(), "[INFO] Register timer for language changed event");
+               delete_language_changed_event_invoker();
+               g_language_changed_event_invoker = ecore_timer_add(0.0, notify_language_changed_event_by_invoker, data);
+               return nullptr;
+       }, static_cast<void *>(params));
 }
 
 static Eina_Bool notify_enabled_changed_event_by_invoker(void *data)
@@ -270,8 +278,12 @@ static void notify_enabled_changed(bool enable)
                return;
        }
 
-       delete_enabled_changed_event_invoker();
-       g_enabled_changed_event_invoker = ecore_timer_add(0.0, notify_enabled_changed_event_by_invoker, static_cast<void *>(param));
+       ecore_main_loop_thread_safe_call_sync([](void *data) -> void * {
+               SLOG(LOG_INFO, vc_config_tag(), "[INFO] Register timer for enabled changed event");
+               delete_enabled_changed_event_invoker();
+               g_enabled_changed_event_invoker = ecore_timer_add(0.0, notify_enabled_changed_event_by_invoker, data);
+               return nullptr;
+       }, static_cast<void *>(param));
 }
 
 static int initialize_config_info()