Merge "DALi Version 2.3.2" into devel/master
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 8 Dec 2023 11:24:34 +0000 (11:24 +0000)
committerGerrit Code Review <gerrit@review>
Fri, 8 Dec 2023 11:24:34 +0000 (11:24 +0000)
dali/internal/adaptor/common/adaptor-impl.cpp
dali/internal/adaptor/common/adaptor-impl.h
dali/internal/adaptor/common/adaptor.cpp
dali/internal/adaptor/common/application-impl.cpp
dali/internal/offscreen/common/offscreen-application-impl.cpp
dali/internal/system/common/async-task-manager-impl.cpp

index c64cbdc..6001eb6 100644 (file)
@@ -663,12 +663,12 @@ Dali::TtsPlayer Adaptor::GetTtsPlayer(Dali::TtsPlayer::Mode mode)
   return mTtsPlayers[mode];
 }
 
-bool Adaptor::AddIdle(CallbackBase* callback, bool hasReturnValue, bool forceAdd)
+bool Adaptor::AddIdle(CallbackBase* callback, bool hasReturnValue)
 {
   bool idleAdded(false);
 
-  // Only add an idle if the Adaptor is actually running
-  if(RUNNING == mState || READY == mState || forceAdd)
+  // We want to run the processes even when paused
+  if(STOPPED != mState)
   {
     idleAdded = mCallbackManager->AddIdleCallback(callback, hasReturnValue);
   }
@@ -1004,7 +1004,7 @@ void Adaptor::RequestProcessEventsOnIdle()
     if(!mNotificationOnIdleInstalled)
     {
       // If we haven't installed the idle notification, install it idle enterer.
-      mNotificationOnIdleInstalled = AddIdleEnterer(MakeCallback(this, &Adaptor::ProcessCoreEventsFromIdle), true);
+      mNotificationOnIdleInstalled = AddIdleEnterer(MakeCallback(this, &Adaptor::ProcessCoreEventsFromIdle));
     }
     else
     {
@@ -1337,12 +1337,12 @@ void Adaptor::SetRootLayoutDirection(std::string locale)
   }
 }
 
-bool Adaptor::AddIdleEnterer(CallbackBase* callback, bool forceAdd)
+bool Adaptor::AddIdleEnterer(CallbackBase* callback)
 {
   bool idleAdded(false);
 
-  // Only add an idle if the Adaptor is actually running
-  if(RUNNING == mState || READY == mState || forceAdd)
+  // We want to run the processes even when paused
+  if(STOPPED != mState)
   {
     idleAdded = mCallbackManager->AddIdleEntererCallback(callback);
   }
index 279ff14..98d1dbc 100644 (file)
@@ -249,7 +249,7 @@ public: // AdaptorInternalServices implementation
   /**
    * @copydoc Dali::Adaptor::AddIdle()
    */
-  virtual bool AddIdle(CallbackBase* callback, bool hasReturnValue, bool forceAdd);
+  virtual bool AddIdle(CallbackBase* callback, bool hasReturnValue);
 
   /**
    * Adds a new Window instance to the Adaptor
@@ -652,7 +652,7 @@ private:
    * @endcode
    * This callback will be called repeatedly as long as it returns true. A return of 0 deletes this callback.
    */
-  bool AddIdleEnterer(CallbackBase* callback, bool forceAdd);
+  bool AddIdleEnterer(CallbackBase* callback);
 
   /**
    * Removes a previously added the idle enterer callback.
index 6ca95b2..c8d17ee 100644 (file)
@@ -88,7 +88,7 @@ void Adaptor::Stop()
 bool Adaptor::AddIdle(CallbackBase* callback, bool hasReturnValue)
 {
   DALI_ASSERT_ALWAYS(IsAvailable() && "Adaptor not instantiated");
-  return mImpl->AddIdle(callback, hasReturnValue, false);
+  return mImpl->AddIdle(callback, hasReturnValue);
 }
 
 bool Adaptor::AddWindow(Dali::Integration::SceneHolder childWindow)
index 0f18afa..44d4146 100644 (file)
@@ -346,7 +346,7 @@ void Application::Quit()
 {
   // Actually quit the application.
   // Force a call to Quit even if adaptor is not running.
-  Internal::Adaptor::Adaptor::GetImplementation(*mAdaptor).AddIdle(MakeCallback(this, &Application::QuitFromMainLoop), false, true);
+  Internal::Adaptor::Adaptor::GetImplementation(*mAdaptor).AddIdle(MakeCallback(this, &Application::QuitFromMainLoop), false);
 }
 
 void Application::QuitFromMainLoop()
index 1b2545a..f1fc2e7 100644 (file)
@@ -89,8 +89,7 @@ void OffscreenApplication::MainLoop()
 void OffscreenApplication::Quit()
 {
   // Actually quit the application.
-  // Force a call to Quit even if adaptor is not running.
-  Internal::Adaptor::Adaptor::GetImplementation(*mAdaptor).AddIdle(MakeCallback(this, &OffscreenApplication::QuitFromMainLoop), false, true);
+  Internal::Adaptor::Adaptor::GetImplementation(*mAdaptor).AddIdle(MakeCallback(this, &OffscreenApplication::QuitFromMainLoop), false);
 }
 
 Dali::OffscreenWindow OffscreenApplication::GetWindow()
index b23a24f..1fdb733 100644 (file)
@@ -1003,6 +1003,22 @@ AsyncTaskPtr AsyncTaskManager::PopNextTaskToProcess()
         taskAvaliable = (mAvaliableLowPriorityTaskCounts > 0u); // priority is low, but we can use it.
       }
 
+      // Check whether we try to running same task at multiple threads.
+      if(taskAvaliable)
+      {
+        Mutex::ScopedLock lock(mRunningTasksMutex); // We can lock this mutex under mWaitingTasksMutex.
+        auto              mapIter = mCacheImpl->mRunningTasksCache.find((*iter).Get());
+        if(mapIter != mCacheImpl->mRunningTasksCache.end())
+        {
+          if(!mapIter->second.empty())
+          {
+            // Some other thread running this tasks now. Ignore it.
+            DALI_LOG_INFO(gAsyncTasksManagerLogFilter, Debug::Verbose, "Some other thread running this task [%p]\n", (*iter).Get());
+            taskAvaliable = false;
+          }
+        }
+      }
+
       if(taskAvaliable)
       {
         nextTask = *iter;