From c0ea6a6b96e0b849586a06019ff69cc810ea9032 Mon Sep 17 00:00:00 2001 From: y00576111 Date: Sun, 6 Feb 2022 19:54:30 +0800 Subject: [PATCH] Support actor function When the worker thread is started the part shared by the virtual machine is not recreated only the part that cannot be shared is created issue:https://gitee.com/openharmony/js_worker_module/issues/I4SMW8 Signed-off-by: y00576111 Change-Id: I9bf9ba9a5f1b6b2a1df6ebb2827c68bdf95d94f9 --- jsapi/worker/worker.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/jsapi/worker/worker.cpp b/jsapi/worker/worker.cpp index 2ca2465..57ffe95 100644 --- a/jsapi/worker/worker.cpp +++ b/jsapi/worker/worker.cpp @@ -76,6 +76,7 @@ void CallWorkCallback(napi_env env, napi_value recv, size_t argc, const napi_val bool Worker::PrepareForWorkerInstance() { std::vector scriptContent; + std::string workerAmi; { std::lock_guard lock(liveStatusLock_); if (HostIsStop()) { @@ -94,14 +95,14 @@ bool Worker::PrepareForWorkerInstance() return false; } // 3. get uril content - if (!hostEngine->CallGetAssetFunc(script_, scriptContent)) { + if (!hostEngine->CallGetAssetFunc(script_, scriptContent, workerAmi)) { HILOG_ERROR("worker:: CallGetAssetFunc error"); return false; } } HILOG_INFO("worker:: stringContent size is %{public}zu", scriptContent.size()); napi_value execScriptResult = nullptr; - napi_run_buffer_script(workerEnv_, scriptContent, &execScriptResult); + napi_run_actor(workerEnv_, scriptContent, workerAmi.c_str(), &execScriptResult); if (execScriptResult == nullptr) { // An exception occurred when running the script. HILOG_ERROR("worker:: run script exception occurs, will handle exception"); -- Gitee