mirror of
https://gitee.com/openharmony/arkui_ace_engine
synced 2025-03-03 13:50:53 +00:00
solve task remove import TraceId memory overflow
Signed-off-by: zhangjiayong1 <zhangjiayong3@huawei.com>
This commit is contained in:
parent
3bbcd6da11
commit
305a709b3a
@ -246,6 +246,25 @@ public:
|
||||
return PostSyncTask(CancelableTask(task), type, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Post a delayed task without traceId to the specified thread.
|
||||
* Never allow to post a background delayed task.
|
||||
*
|
||||
* @param task Task which need execution.
|
||||
* @param type FrontendType of task, used to specify the thread.
|
||||
* @param delayTime Wait a period of time in milliseconds before execution.
|
||||
* @param name Name of the task.
|
||||
* @return Returns 'true' if task has been posted successfully.
|
||||
*/
|
||||
bool PostDelayedTaskWithoutTraceId(Task&& task, TaskType type, uint32_t delayTime, const std::string& name,
|
||||
PriorityType priorityType = PriorityType::LOW) const
|
||||
{
|
||||
if (delayTime > 0 && type == TaskType::BACKGROUND) {
|
||||
return false;
|
||||
}
|
||||
return OnPostTaskWithoutTraceId(std::move(task), type, delayTime, name, priorityType);
|
||||
}
|
||||
|
||||
virtual void AddTaskObserver(Task&& callback) = 0;
|
||||
virtual void RemoveTaskObserver() = 0;
|
||||
virtual bool WillRunOnCurrentThread(TaskType type) const = 0;
|
||||
@ -267,6 +286,8 @@ protected:
|
||||
virtual bool OnPostTask(Task&& task, TaskType type, uint32_t delayTime, const std::string& name,
|
||||
PriorityType priorityType = PriorityType::LOW) const = 0;
|
||||
virtual Task WrapTaskWithTraceId(Task&& task, int32_t id) const = 0;
|
||||
virtual bool OnPostTaskWithoutTraceId(Task&& task, TaskType type, uint32_t delayTime, const std::string& name,
|
||||
PriorityType priorityType = PriorityType::LOW) const = 0;
|
||||
|
||||
#ifdef ACE_DEBUG
|
||||
virtual bool OnPreSyncTask(TaskType type) const
|
||||
|
@ -355,6 +355,30 @@ void TaskExecutorImpl::FillTaskTypeTable(const WeakPtr<TaskExecutorImpl>& weak,
|
||||
}
|
||||
}
|
||||
|
||||
bool TaskExecutorImpl::OnPostTaskWithoutTraceId(
|
||||
Task&& task, TaskType type, uint32_t delayTime, const std::string& name, PriorityType priorityType) const
|
||||
{
|
||||
TaskExecutor::Task wrappedTask = std::move(task);
|
||||
|
||||
switch (type) {
|
||||
case TaskType::PLATFORM:
|
||||
return PostTaskToTaskRunner(platformRunner_, std::move(wrappedTask), delayTime, name);
|
||||
case TaskType::UI:
|
||||
return PostTaskToTaskRunner(uiRunner_, std::move(wrappedTask), delayTime, name, priorityType);
|
||||
case TaskType::IO:
|
||||
return PostTaskToTaskRunner(ioRunner_, std::move(wrappedTask), delayTime, name);
|
||||
case TaskType::GPU:
|
||||
return PostTaskToTaskRunner(gpuRunner_, std::move(wrappedTask), delayTime, name);
|
||||
case TaskType::JS:
|
||||
return PostTaskToTaskRunner(jsRunner_, std::move(wrappedTask), delayTime, name);
|
||||
case TaskType::BACKGROUND:
|
||||
// Ignore delay time
|
||||
return BackgroundTaskExecutor::GetInstance().PostTask(std::move(wrappedTask));
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void TaskExecutorImpl::RemoveTask(TaskType type, const std::string &name)
|
||||
{
|
||||
switch (type) {
|
||||
|
@ -69,6 +69,8 @@ private:
|
||||
PriorityType priorityType = PriorityType::LOW) const final;
|
||||
Task WrapTaskWithTraceId(Task&& task, int32_t id) const final;
|
||||
void RemoveTaskFromTaskRunner(const RefPtr<TaskRunnerAdapter>& taskRunner, const std::string& name);
|
||||
bool OnPostTaskWithoutTraceId(Task&& task, TaskType type, uint32_t delayTime, const std::string& name,
|
||||
PriorityType priorityType = PriorityType::LOW) const final;
|
||||
|
||||
#ifdef ACE_DEBUG
|
||||
bool OnPreSyncTask(TaskType type) const final;
|
||||
|
@ -136,7 +136,7 @@ void RosenWindow::RequestFrame()
|
||||
LOGE("ArkUI request vsync,but no vsync was received within 3 seconds");
|
||||
EventReport::SendVsyncException(VsyncExcepType::UI_VSYNC_TIMEOUT, windowId, instanceId, timeStamp);
|
||||
};
|
||||
taskExecutor->PostDelayedTask(task, TaskExecutor::TaskType::JS,
|
||||
taskExecutor->PostDelayedTaskWithoutTraceId(task, TaskExecutor::TaskType::JS,
|
||||
VSYNC_TASK_DELAY_MILLISECOND, "ArkUIVsyncTimeoutCheck");
|
||||
}
|
||||
#endif
|
||||
|
@ -47,6 +47,14 @@ public:
|
||||
void RemoveTaskObserver() override {}
|
||||
|
||||
void RemoveTask(TaskType type, const std::string &name) override {}
|
||||
|
||||
bool OnPostTaskWithoutTraceId(Task&& task, TaskType type, uint32_t delayTime, const std::string& name,
|
||||
PriorityType priorityType = PriorityType::LOW) const override
|
||||
{
|
||||
CHECK_NULL_RETURN(task, false);
|
||||
task();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
} // namespace OHOS::Ace
|
||||
#endif // FOUNDATION_ACE_FRAMEWORKS_CORE_PIPELINE_NG_TEST_MOCK_MOCK_TASK_EXECUTOR_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user