[TIzen] Add API for check core shutting down or not 06/299306/1
authorEunki Hong <eunkiki.hong@samsung.com>
Mon, 25 Sep 2023 09:56:35 +0000 (18:56 +0900)
committerEunki Hong <eunkiki.hong@samsung.com>
Mon, 25 Sep 2023 12:10:24 +0000 (21:10 +0900)
Add some API to check whether the core is shutting down or not,
So out of dali-core side can also know it.

Also, Make combined helper API to check whether core installed before or not.
It will be useful when we check worker thread access into UI classes of dali.

Change-Id: I2d8d3120b4fc959056f4644846d3d14a3b89bcc6
Signed-off-by: Eunki Hong <eunkiki.hong@samsung.com>
automated-tests/src/dali/utc-Dali-Stage.cpp
dali/devel-api/common/stage.cpp
dali/devel-api/common/stage.h
dali/internal/event/common/stage-impl.cpp
dali/internal/event/common/stage-impl.h

index b9b8050..4105e04 100644 (file)
@@ -387,6 +387,45 @@ int UtcDaliStageIsInstalledN(void)
   END_TEST;
 }
 
+int UtcDaliStageIsShuttingDown(void)
+{
+  DALI_TEST_CHECK(!Stage::IsShuttingDown());
+
+  {
+    TestApplication application;
+
+    DALI_TEST_CHECK(!Stage::IsShuttingDown());
+
+    Stage::GetCurrent();
+
+    DALI_TEST_CHECK(!Stage::IsShuttingDown());
+  }
+
+  // Core destroyed
+  DALI_TEST_CHECK(Stage::IsShuttingDown());
+  END_TEST;
+}
+
+int UtcDaliStageIsCoreInstalled(void)
+{
+  DALI_TEST_CHECK(!Stage::IsCoreInstalled());
+
+  {
+    TestApplication application;
+
+    DALI_TEST_CHECK(Stage::IsCoreInstalled());
+
+    Stage::GetCurrent();
+
+    DALI_TEST_CHECK(Stage::IsCoreInstalled());
+  }
+
+  // Core destroyed
+  DALI_TEST_CHECK(Stage::IsCoreInstalled());
+  END_TEST;
+}
+
+
 int UtcDaliStageCopyConstructorP(void)
 {
   TestApplication application;
index 02f361f..9e013b0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -59,6 +59,17 @@ bool Stage::IsInstalled()
   return Internal::Stage::IsInstalled();
 }
 
+bool Stage::IsShuttingDown()
+{
+  return Internal::Stage::IsShuttingDown();
+}
+
+bool Stage::IsCoreInstalled()
+{
+  return IsInstalled() ||  ///< Check if Core is installed now,
+         IsShuttingDown(); ///< or Core is shutting down now.
+}
+
 void Stage::Add(Actor& actor)
 {
   GetImplementation(*this).Add(GetImplementation(actor));
index cf271cf..ad94e37 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_STAGE_H
 
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -114,6 +114,21 @@ public:
   static bool IsInstalled();
 
   /**
+   * @brief Queries whether the Stage shutting down now; this should only return false during or before destruction of Dali core.
+   *
+   * @return True when Dali core destructor called.
+   */
+  static bool IsShuttingDown();
+
+  /**
+   * @brief Queries whether we installed Dali core before, or not.
+   * It will be useful whether you want to check we are on valid ui thread or not, after Core initalized ensured.
+   *
+   * @return True when Dali core destructor called.
+   */
+  static bool IsCoreInstalled();
+
+  /**
    * @brief Destructor.
    *
    * This is non-virtual since derived Handle types must not contain data or virtual methods.
index d2309d6..ae0b7d2 100644 (file)
@@ -112,6 +112,11 @@ bool Stage::IsInstalled()
   return ThreadLocalStorage::Created();
 }
 
+bool Stage::IsShuttingDown()
+{
+  return ThreadLocalStorage::IsShuttingDown();
+}
+
 ObjectRegistry& Stage::GetObjectRegistry()
 {
   return ThreadLocalStorage::Get().GetObjectRegistry();
index 8711fcf..8b4abed 100644 (file)
@@ -90,6 +90,11 @@ public:
   static bool IsInstalled();
 
   /**
+   * @copydoc Dali::Stage::IsShuttingDown().
+   */
+  static bool IsShuttingDown();
+
+  /**
    * @copydoc Dali::Stage::GetObjectRegistry()
    */
   ObjectRegistry& GetObjectRegistry();