summaryrefslogtreecommitdiff
path: root/dali
diff options
context:
space:
mode:
authorSeungho Baek <sbsh.baek@samsung.com>2024-04-24 14:20:09 +0900
committerSeungho Baek <sbsh.baek@samsung.com>2024-04-24 14:32:56 +0900
commit6eeb61f73dad0d2ebbbf23cb091658130a1c019f (patch)
tree304105d6d57a26ad7be3c06f97427d2624a99203 /dali
parent3141db6d3fe4fcec09a741626208d9fdddab46b2 (diff)
downloaddali-adaptor-6eeb61f73dad0d2ebbbf23cb091658130a1c019f.tar.gz
dali-adaptor-6eeb61f73dad0d2ebbbf23cb091658130a1c019f.tar.bz2
dali-adaptor-6eeb61f73dad0d2ebbbf23cb091658130a1c019f.zip
Block to do not access mTasks from multiple threads
- RoundRobinContainerView is not ThreadSafe. - If 2 or more Thread call GetNext() method at the same time, it can return cend(). - This patch blocks to do not access mTasks from multiple threads. - Blocked code is works for only simple request with O(n). Change-Id: I134a846cfa04935d4e492f4d3a92c65eaa169261 Signed-off-by: Seungho Baek <sbsh.baek@samsung.com>
Diffstat (limited to 'dali')
-rw-r--r--dali/internal/system/common/async-task-manager-impl.cpp19
-rw-r--r--dali/internal/system/common/async-task-manager-impl.h1
2 files changed, 12 insertions, 8 deletions
diff --git a/dali/internal/system/common/async-task-manager-impl.cpp b/dali/internal/system/common/async-task-manager-impl.cpp
index 2f2a2bf8a..ab0c6465d 100644
--- a/dali/internal/system/common/async-task-manager-impl.cpp
+++ b/dali/internal/system/common/async-task-manager-impl.cpp
@@ -670,17 +670,20 @@ void AsyncTaskManager::AddTask(AsyncTaskPtr task)
}
}
- size_t count = mTasks.GetElementCount();
- size_t index = 0;
- while(index++ < count)
{
- auto processHelperIt = mTasks.GetNext();
- DALI_ASSERT_ALWAYS(processHelperIt != mTasks.End());
- if(processHelperIt->Request())
+ Mutex::ScopedLock lock(mTasksMutex);
+ size_t count = mTasks.GetElementCount();
+ size_t index = 0;
+ while(index++ < count)
{
- break;
+ auto processHelperIt = mTasks.GetNext();
+ DALI_ASSERT_ALWAYS(processHelperIt != mTasks.End());
+ if(processHelperIt->Request())
+ {
+ break;
+ }
+ // If all threads are busy, then it's ok just to push the task because they will try to get the next job.
}
- // If all threads are busy, then it's ok just to push the task because they will try to get the next job.
}
// Register Process (Since mTrigger execute too late timing if event thread running a lots of events.)
diff --git a/dali/internal/system/common/async-task-manager-impl.h b/dali/internal/system/common/async-task-manager-impl.h
index 7729ff5f0..4edf53830 100644
--- a/dali/internal/system/common/async-task-manager-impl.h
+++ b/dali/internal/system/common/async-task-manager-impl.h
@@ -270,6 +270,7 @@ private:
Dali::Mutex mWaitingTasksMutex; ///< Mutex for mWaitingTasks. We can lock mRunningTasksMutex and mCompletedTasksMutex under this scope.
Dali::Mutex mRunningTasksMutex; ///< Mutex for mRunningTasks. We can lock mCompletedTasksMutex under this scope.
Dali::Mutex mCompletedTasksMutex; ///< Mutex for mCompletedTasks. We cannot lock any mutex under this scope.
+ Dali::Mutex mTasksMutex; ///< Mutex for mTasks. We cannot lock any mutex under this scope.
std::unique_ptr<EventThreadCallback> mTrigger;