Since we destruct AsyncTask only on main thread,
it may collects too much AsyncTasks on complete tasks.
To avoid stacking the tasks, let we trigger the callback forcely
if the number of complete tasks is big enough.
Change-Id: I9a7a52404da56e24355f72a8a5532e8bf8b2d1b8
Signed-off-by: Eunki, Hong <eunkiki.hong@samsung.com>
{
namespace
{
+constexpr auto FORCE_TRIGGER_THRESHOLD = 128u; ///< Trigger TasksCompleted() forcely if the number of completed task contain too much.
+
constexpr auto DEFAULT_NUMBER_OF_ASYNC_THREADS = size_t{8u};
constexpr auto NUMBER_OF_ASYNC_THREADS_ENV = "DALI_ASYNC_MANAGER_THREAD_POOL_SIZE";
if(task)
{
- const bool needTrigger = task->GetCallbackInvocationThread() == AsyncTask::ThreadType::MAIN_THREAD;
+ bool needTrigger = (task->GetCallbackInvocationThread() == AsyncTask::ThreadType::MAIN_THREAD);
// Lock while check validation of task.
{
CacheImpl::EraseTaskCache(mCacheImpl->mRunningTasksCache, task, iter);
mRunningTasks.erase(iter);
+ if(!needTrigger)
+ {
+ needTrigger |= (mCompletedTasks.size() >= FORCE_TRIGGER_THRESHOLD);
+ }
+
// Now, task is invalidate.
task.Reset();
}