!43616 记录不可取消任务的config

Merge pull request !43616 from Far/updatepromisetask
This commit is contained in:
openharmony_ci 2024-09-24 09:25:12 +00:00 committed by Gitee
commit a5fe84fb13
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 14 additions and 1 deletions

View File

@ -2527,7 +2527,8 @@ void UIContentImpl::UpdateViewportConfigWithAnimation(const ViewportConfig& conf
} else if (rsTransaction != nullptr || isAvoidAreaDoChanged) {
// When rsTransaction is not nullptr, the task contains animation. It shouldn't be cancled.
// When avoidAreas need updating, the task shouldn't be cancelled.
taskExecutor->PostTask(std::move(task), TaskExecutor::TaskType::PLATFORM, "ArkUIUpdateViewportConfig");
viewportConfigMgr_->UpdatePromiseConfig(aceViewportConfig, std::move(task), container,
"ArkUIPromiseViewportConfig");
} else {
viewportConfigMgr_->UpdateConfig(aceViewportConfig, std::move(task), container, "ArkUIUpdateViewportConfig");
}

View File

@ -47,6 +47,18 @@ public:
task();
}
void UpdatePromiseConfig(const T& config, std::function<void()> &&task, const RefPtr<Container>& container,
const std::string& taskName, TaskExecutor::TaskType type = TaskExecutor::TaskType::PLATFORM)
{
std::lock_guard<std::mutex> taskLock(updateTaskMutex_);
CancelUselessTaskLocked();
currentTask_.target = config;
auto taskExecutor = container->GetTaskExecutor();
CHECK_NULL_VOID(taskExecutor);
taskExecutor->PostTask(std::move(task), type, taskName);
}
void UpdateConfig(const T& config, std::function<void()> &&task, const RefPtr<Container>& container,
const std::string& taskName, TaskExecutor::TaskType type = TaskExecutor::TaskType::PLATFORM)
{