From a5bccd3a92faf3f33583b0db86f869d2f6b97667 Mon Sep 17 00:00:00 2001 From: zhangzezhong Date: Wed, 28 May 2025 21:49:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=88=90=E5=91=98=E5=8F=98?= =?UTF-8?q?=E9=87=8F=E7=BA=BF=E7=A8=8B=E5=AE=89=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhangzezhong --- .../native/runtime/js_runtime_common.cpp | 26 +++++++++---------- .../runtime/include/js_runtime_common.h | 6 ++--- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/frameworks/native/runtime/js_runtime_common.cpp b/frameworks/native/runtime/js_runtime_common.cpp index 9ecfc077935..12284ea2b2a 100644 --- a/frameworks/native/runtime/js_runtime_common.cpp +++ b/frameworks/native/runtime/js_runtime_common.cpp @@ -36,39 +36,39 @@ JsRuntimeCommon::~JsRuntimeCommon() {} bool JsRuntimeCommon::IsDebugMode() { - return debugMode_; + return debugMode_.load(); } bool JsRuntimeCommon::IsDebugApp() { - return debugApp_; + return debugApp_.load(); } bool JsRuntimeCommon::IsNativeStart() { - return nativeStart_; + return nativeStart_.load(); } void JsRuntimeCommon::SetDebugMode(bool isDebugMode) { - debugMode_ = isDebugMode; + debugMode_.store(isDebugMode); } void JsRuntimeCommon::SetDebugApp(bool isDebugApp) { - debugApp_ = isDebugApp; + debugApp_.store(isDebugApp); } void JsRuntimeCommon::SetNativeStart(bool isNativeStart) { - nativeStart_ = isNativeStart; + nativeStart_.store(isNativeStart); } void JsRuntimeCommon::StartDebuggerModule(bool isDebugApp, bool isNativeStart) { - debugMode_ = true; - debugApp_ = isDebugApp; - nativeStart_ = isNativeStart; + debugMode_.store(true); + debugApp_.store(isDebugApp); + nativeStart_.store(isNativeStart); } napi_status JsRuntimeCommon::StartDebugMode(NativeEngine* nativeEngine, const std::string& threadName) @@ -77,13 +77,13 @@ napi_status JsRuntimeCommon::StartDebugMode(NativeEngine* nativeEngine, const st TAG_LOGE(AAFwkTag::JSRUNTIME, "null nativeEngine"); return napi_status::napi_invalid_arg; } - TAG_LOGI(AAFwkTag::JSRUNTIME, "debug mode is %{public}d, debug app is %{public}d", debugMode_, debugApp_); + TAG_LOGI(AAFwkTag::JSRUNTIME, "debug mode is %{public}d, debug app is %{public}d", IsDebugMode(), IsDebugApp()); auto arkNativeEngine = static_cast(nativeEngine); auto instanceId = panda::DFXJSNApi::GetCurrentThreadId(); TAG_LOGI(AAFwkTag::JSRUNTIME, "Create instanceId is %{public}d", instanceId); std::string instanceName = threadName + "_" + std::to_string(instanceId); bool isAddInstance = ConnectServerManager::Get().AddInstance(instanceId, instanceId, instanceName); - if (nativeStart_) { + if (IsNativeStart()) { TAG_LOGE(AAFwkTag::JSRUNTIME, "native: true, set isAddInstance: false"); isAddInstance = false; } @@ -93,8 +93,8 @@ napi_status JsRuntimeCommon::StartDebugMode(NativeEngine* nativeEngine, const st panda::JSNApi::DebugOption debugOption = {ARK_DEBUGGER_LIB_PATH, isAddInstance}; auto vm = const_cast(arkNativeEngine->GetEcmaVm()); ConnectServerManager::Get().StoreDebuggerInfo( - instanceId, reinterpret_cast(vm), debugOption, postTask, debugApp_); - panda::JSNApi::NotifyDebugMode(instanceId, vm, debugOption, instanceId, postTask, debugApp_); + instanceId, reinterpret_cast(vm), debugOption, postTask, IsDebugApp()); + panda::JSNApi::NotifyDebugMode(instanceId, vm, debugOption, instanceId, postTask, IsDebugApp()); return napi_status::napi_ok; } diff --git a/interfaces/inner_api/runtime/include/js_runtime_common.h b/interfaces/inner_api/runtime/include/js_runtime_common.h index 6e0e9c9e3e8..3c6b8405976 100644 --- a/interfaces/inner_api/runtime/include/js_runtime_common.h +++ b/interfaces/inner_api/runtime/include/js_runtime_common.h @@ -38,9 +38,9 @@ public: private: JsRuntimeCommon(); ~JsRuntimeCommon(); - bool debugMode_ = false; - bool debugApp_ = false; - bool nativeStart_ = false; + std::atomic debugMode_ = false; + std::atomic debugApp_ = false; + std::atomic nativeStart_ = false; }; } // namespace AbilityRuntime } // namespace OHOS -- Gitee