From c3bd652205d85c9890fe6fa1966b7d3fbf76aad9 Mon Sep 17 00:00:00 2001 From: wuliubao Date: Mon, 24 Jan 2022 18:11:27 +0800 Subject: [PATCH] =?UTF-8?q?IssueNo:=20#I4PCO3:=E8=80=97=E6=97=B6=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=20Description:=20=E4=B8=BB=E7=BA=BF=E7=A8=8BEventRunn?= =?UTF-8?q?er=E8=80=97=E6=97=B6=E6=A3=80=E6=B5=8B=20Sig:=20SIG=5FApplicati?= =?UTF-8?q?onFramework=20Feature=20or=20Bugfix:=20Feature=20Binary=20Sourc?= =?UTF-8?q?e:=20No?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wuliubao --- .../appkit/native/app/include/main_thread.h | 7 ++++++ .../appkit/native/app/src/main_thread.cpp | 25 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/frameworks/kits/appkit/native/app/include/main_thread.h b/frameworks/kits/appkit/native/app/include/main_thread.h index 123c0c7f9b6..bf484f587ef 100644 --- a/frameworks/kits/appkit/native/app/include/main_thread.h +++ b/frameworks/kits/appkit/native/app/include/main_thread.h @@ -376,6 +376,13 @@ private: */ void Init(const std::shared_ptr &runner, const std::shared_ptr &watchDogRunner); + /** + * + * @brief Task in event handler timeout detected. + * + */ + void TaskTimeoutDetected(); + /** * * @brief Check whether the OHOSApplication is ready. diff --git a/frameworks/kits/appkit/native/app/src/main_thread.cpp b/frameworks/kits/appkit/native/app/src/main_thread.cpp index 92ea68d88af..f911cef54bd 100644 --- a/frameworks/kits/appkit/native/app/src/main_thread.cpp +++ b/frameworks/kits/appkit/native/app/src/main_thread.cpp @@ -49,6 +49,8 @@ namespace OHOS { namespace AppExecFwk { namespace { constexpr int TARGET_VERSION_THRESHOLDS = 8; +constexpr int32_t DELIVERY_TIME = 200; +constexpr int32_t DISTRIBUTE_TIME = 100; } #define ACEABILITY_LIBRARY_LOADER @@ -1227,6 +1229,28 @@ void MainThread::HandleConfigurationUpdated(const Configuration &config) APP_LOGI("MainThread::HandleConfigurationUpdated called end."); } +void MainThread::TaskTimeoutDetected() +{ + BYTRACE_NAME(BYTRACE_TAG_APP, __PRETTY_FUNCTION__); + APP_LOGI("MainThread::TaskTimeoutDetected called start."); + + auto deliveryTimeoutCallback = []() { + APP_LOGI("MainThread::TaskTimeoutDetected delivery timeout"); + }; + auto distributeTimeoutCallback = []() { + APP_LOGI("MainThread::TaskTimeoutDetected delivery timeout"); + }; + + if (mainHandler_ != nullptr) { + mainHandler_->SetDeliveryTimeout(DELIVERY_TIME); + mainHandler_->SetDeliveryTimeoutCallback(deliveryTimeoutCallback); + + mainHandler_->SetDistributeTimeout(DISTRIBUTE_TIME); + mainHandler_->SetDistributeTimeoutCallback(distributeTimeoutCallback); + } + APP_LOGI("MainThread::TaskTimeoutDetected called end."); +} + void MainThread::Init(const std::shared_ptr &runner, const std::shared_ptr &watchDogRunner) { BYTRACE_NAME(BYTRACE_TAG_APP, __PRETTY_FUNCTION__); @@ -1252,6 +1276,7 @@ void MainThread::Init(const std::shared_ptr &runner, const std::sha if (!watchDogHandler_->PostTask(taskWatchDog)) { APP_LOGE("MainThread::Init WatchDog postTask task failed"); } + TaskTimeoutDetected(); /* watchDogHandler_->Init(mainHandler_, watchDogHandler_); APP_LOGI("MainThread:Init before CreateRunner."); -- Gitee