!10595 appInfoMutex_读锁改为写锁

Merge pull request !10595 from tanliang/lock_fix
This commit is contained in:
openharmony_ci 2024-11-07 13:45:45 +00:00 committed by Gitee
commit 5142d30ca6
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -74,7 +74,7 @@ void MultiInstanceManager::SetCurrentUserId(int32_t userId)
bool MultiInstanceManager::IsMultiInstance(const std::string& bundleName)
{
std::shared_lock<std::shared_mutex> lock(appInfoMutex_);
std::unique_lock<std::shared_mutex> lock(appInfoMutex_);
auto iter = appInfoMap_.find(bundleName);
if (iter == appInfoMap_.end()) {
AppExecFwk::ApplicationInfo appInfo;
@ -91,7 +91,7 @@ bool MultiInstanceManager::IsMultiInstance(const std::string& bundleName)
uint32_t MultiInstanceManager::GetMaxInstanceCount(const std::string& bundleName)
{
std::shared_lock<std::shared_mutex> lock(appInfoMutex_);
std::unique_lock<std::shared_mutex> lock(appInfoMutex_);
auto iter = appInfoMap_.find(bundleName);
if (iter == appInfoMap_.end()) {
AppExecFwk::ApplicationInfo appInfo;