From 41d08008ca8a4fb6074aef271329fcb393ac1518 Mon Sep 17 00:00:00 2001 From: huyx Date: Thu, 29 Aug 2024 15:54:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: huyx --- adapter/uhdf2/hdi/src/object_collector.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/adapter/uhdf2/hdi/src/object_collector.cpp b/adapter/uhdf2/hdi/src/object_collector.cpp index ac6bee61b..b7b146a2a 100644 --- a/adapter/uhdf2/hdi/src/object_collector.cpp +++ b/adapter/uhdf2/hdi/src/object_collector.cpp @@ -15,7 +15,7 @@ #include "object_collector.h" #include - +#include #include "hdf_base.h" #include "hdf_log.h" #include "osal_time.h" @@ -74,12 +74,13 @@ OHOS::sptr ObjectCollector::GetOrNewObject( } RETRY: - std::lock_guard lock(mutex_); + std::unique_lock lock(mutex_); auto it = interfaceObjectCollector_.find(interface.GetRefPtr()); if (it != interfaceObjectCollector_.end()) { if (it->second->GetSptrRefCount() == 0) { // may object is releasing, yield to sync - OsalMSleep(1); + lock.unlock(); + std::this_thread::yield(); goto RETRY; } return it->second.GetRefPtr(); -- Gitee