From 0f4d53413673a2e00ff2f536d10664e17db099b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E6=98=8E=E6=9D=B0?= Date: Wed, 16 Oct 2024 17:16:26 +0800 Subject: [PATCH] 1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 朱明杰 --- ressched/common/include/oobe_manager.h | 2 +- ressched/common/src/oobe_manager.cpp | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ressched/common/include/oobe_manager.h b/ressched/common/include/oobe_manager.h index c40f5262..b875b62a 100644 --- a/ressched/common/include/oobe_manager.h +++ b/ressched/common/include/oobe_manager.h @@ -49,7 +49,7 @@ private: }; bool g_oobeValue = false; - static std::mutex mutex_; + static std::recursive_mutex mutex_; static std::vector> oobeTasks_; static std::vector> dataShareFunctions_; static sptr observer_; diff --git a/ressched/common/src/oobe_manager.cpp b/ressched/common/src/oobe_manager.cpp index 19f6c7a8..bd80d824 100644 --- a/ressched/common/src/oobe_manager.cpp +++ b/ressched/common/src/oobe_manager.cpp @@ -22,7 +22,7 @@ namespace OHOS { namespace ResourceSchedule { -std::mutex OOBEManager::mutex_; +std::recursive_mutex OOBEManager::mutex_; std::vector> OOBEManager::oobeTasks_; std::vector> OOBEManager::dataShareFunctions_; sptr OOBEManager::observer_ = nullptr; @@ -48,13 +48,13 @@ OOBEManager& OOBEManager::GetInstance() bool OOBEManager::GetOOBValue() { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); return g_oobeValue; } ErrCode OOBEManager::RegisterObserver(const std::string& key, const ResDataAbilityObserver::UpdateFunc& func) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (!DataShareUtils::GetInstance().GetDataShareReadyFlag()) { RESSCHED_LOGE("RegisterObserver: dataShare is not ready!"); std::function dataShareFunction = [key, func, this]() { @@ -141,7 +141,7 @@ void OOBEManager::Initialize() bool OOBEManager::SubmitTask(const std::shared_ptr& task) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); if (task == nullptr) { RESSCHED_LOGE("Bad task passed!"); return false; @@ -159,7 +159,7 @@ void OOBEManager::StartListen() int resultValue = 0; ResourceSchedule::DataShareUtils::GetInstance().GetValue(KEYWORD, resultValue); if (resultValue != 0) { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); g_oobeValue = true; for (auto task : oobeTasks_) { task->ExcutingTask(); @@ -171,7 +171,7 @@ void OOBEManager::StartListen() ResourceSchedule::DataShareUtils::GetInstance().GetValue(KEYWORD, result); if (result != 0) { RESSCHED_LOGI("User consent authorization!"); - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); g_oobeValue = true; for (auto task : oobeTasks_) { task->ExcutingTask(); @@ -186,7 +186,7 @@ void OOBEManager::StartListen() void OOBEManager::OnReceiveDataShareReadyCallBack() { - std::lock_guard lock(mutex_); + std::lock_guard lock(mutex_); for (auto function : dataShareFunctions_) { function(); } -- Gitee