mirror of
https://github.com/openharmony/js_worker_module.git
synced 2026-07-19 11:22:56 -04:00
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 <yaojian16@huawei.com> Change-Id: I9bf9ba9a5f1b6b2a1df6ebb2827c68bdf95d94f9
This commit is contained in:
@@ -77,6 +77,7 @@ void CallWorkCallback(napi_env env, napi_value recv, size_t argc, const napi_val
|
||||
bool Worker::PrepareForWorkerInstance()
|
||||
{
|
||||
std::vector<uint8_t> scriptContent;
|
||||
std::string workerAmi;
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(liveStatusLock_);
|
||||
if (HostIsStop()) {
|
||||
@@ -95,14 +96,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");
|
||||
|
||||
Reference in New Issue
Block a user