diff --git a/ressched/common/include/oobe_manager.h b/ressched/common/include/oobe_manager.h index c40f52623ca4f73bf37b23f4d72f6310c7295660..b875b62a68a2fb4cca4087febf1e340923bbb6c1 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 19f6c7a80bac874f46b5b45026f446886b3ac509..bd80d824581b16289d37bafa9c9b0282a9f6bb83 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(); }