mirror of
https://github.com/openharmony/js_worker_module.git
synced 2026-07-01 07:24:25 -04:00
format repair
For internal issues raised by Huawei, modify README files, related copyright information, etc. Related issue: https://gitee.com/openharmony/js_worker_module/issues/I4XAYE Signed-off-by: xdmal <maxiaodong16@huawei.com>
This commit is contained in:
@@ -71,8 +71,7 @@ worker.on("alert", (e)=>{
|
||||
|
||||
- name
|
||||
|
||||
| once(type:string, listener:EventListener) | Adds an event listener to the worker and
|
||||
removes the event listener automically after it is invoked once |
|
||||
| once(type:string, listener:EventListener) | Adds an event listener to the worker and removes the event listener automically after it is invoked once |
|
||||
|---|---|
|
||||
|
||||
- example
|
||||
@@ -166,8 +165,7 @@ worker.removeAllListener();
|
||||
|
||||
- name
|
||||
|
||||
| onexit?:(code:number)=>void | The onexit attribute of the worker specifies the event handler to be called
|
||||
when the worker exits. The handler is executed in the host thread |
|
||||
| onexit?:(code:number)=>void | The onexit attribute of the worker specifies the event handler to be called when the worker exits. The handler is executed in the host thread |
|
||||
|---|---|
|
||||
|
||||
- example
|
||||
@@ -184,8 +182,7 @@ worker.onexit = function(e) {
|
||||
|
||||
- name
|
||||
|
||||
| onerror?:(ev:ErrorEvent)=>void | The onerror attribute of the worker specifies the event handler to be called
|
||||
when an exception occurs during worker execution. The event handler is executed in the host thread |
|
||||
| onerror?:(ev:ErrorEvent)=>void | The onerror attribute of the worker specifies the event handler to be called when an exception occurs during worker execution. The event handler is executed in the host thread |
|
||||
|---|---|
|
||||
|
||||
- example
|
||||
@@ -202,9 +199,7 @@ worker.onerror = function(e) {
|
||||
|
||||
- name
|
||||
|
||||
| onmessage?:(ev:MessageEvent)=>void | The onmessage attribute of the worker specifies the event handler to be called
|
||||
then the host thread receives a message created by itself and sent by the worker through the parentPort.postMessage.
|
||||
The event handler is executed in the host thread |
|
||||
| onmessage?:(ev:MessageEvent)=>void | The onmessage attribute of the worker specifies the event handler to be called then the host thread receives a message created by itself and sent by the worker through the parentPort.postMessage. The event handler is executed in the host thread |
|
||||
|---|---|
|
||||
|
||||
- example
|
||||
@@ -221,8 +216,7 @@ worker.onmessage = function(e) {
|
||||
|
||||
- name
|
||||
|
||||
| onmessageerror?:(event:MessageEvent)=>void | The onmessage attribute of the worker specifies the event handler
|
||||
when the worker receives a message that cannot be serialized. The event handler is executed in the host thread |
|
||||
| onmessageerror?:(event:MessageEvent)=>void | The onmessage attribute of the worker specifies the event handler when the worker receives a message that cannot be serialized. The event handler is executed in the host thread |
|
||||
|---|---|
|
||||
|
||||
- example
|
||||
@@ -294,9 +288,7 @@ parentPort.onmessage = function(e) {
|
||||
|
||||
- name
|
||||
|
||||
| onmessage?:(event:MessageEvent)=>void | The onmessage attribute of parentPort specifies the event handler to be called
|
||||
then the worker thread receives a message sent by the host thread through worker postMessage.
|
||||
The event handler is executed in the worker thread |
|
||||
| onmessage?:(event:MessageEvent)=>void | The onmessage attribute of parentPort specifies the event handler to be called then the worker thread receives a message sent by the host thread through worker postMessage. The event handler is executed in the worker thread |
|
||||
|---|---|
|
||||
|
||||
- example
|
||||
@@ -319,8 +311,7 @@ parentPort.onmessage = function(e) {
|
||||
|
||||
- name
|
||||
|
||||
| onerror?:(ev: ErrorEvent)=>void | The onerror attribute of parentPort specifies the event handler to be called
|
||||
when an exception occurs during worker execution. The event handler is executed in the worker thread |
|
||||
| onerror?:(ev: ErrorEvent)=>void | The onerror attribute of parentPort specifies the event handler to be called when an exception occurs during worker execution. The event handler is executed in the worker thread |
|
||||
|---|---|
|
||||
|
||||
- example
|
||||
@@ -344,8 +335,7 @@ parentPort.onerror = function(e) {
|
||||
|
||||
- name
|
||||
|
||||
| onmessageerror?:(event: MessageEvent)=>void | The onmessage attribute of parentPort specifies the event handler to be called
|
||||
then the worker receives a message that cannot be deserialized. The event handler is executed in the worker thread. |
|
||||
| onmessageerror?:(event: MessageEvent)=>void | The onmessage attribute of parentPort specifies the event handler to be called then the worker receives a message that cannot be deserialized. The event handler is executed in the worker thread. |
|
||||
|---|---|
|
||||
|
||||
- example
|
||||
@@ -366,8 +356,11 @@ parentPort.onmessageerror = function(e) {
|
||||
|
||||
### Repositories Involved
|
||||
|
||||
- ace_ace_engine
|
||||
- ace_napi
|
||||
- ace_ace_engine(foundation/ace/ace_engine-readme.md)
|
||||
- ace_napi(foundation/ace/napi-readme.md)
|
||||
|
||||
## Related warehouse
|
||||
[js_worker_module Subsystem](base/compileruntime/js_worker_module-readme.md)
|
||||
|
||||
### License
|
||||
|
||||
|
||||
+7
-4
@@ -288,8 +288,7 @@ parentPort.onmessage = function(e) {
|
||||
|
||||
- 属性名
|
||||
|
||||
| onmessage?:(event:MessageEvent)=>void | 宿主线程收到来自其创建的worker通过worker.postMessage接口发送的消息时被调用的事件处理程序,
|
||||
处理程序在worker线程中执行 |
|
||||
| onmessage?:(event:MessageEvent)=>void | 宿主线程收到来自其创建的worker通过worker.postMessage接口发送的消息时被调用的事件处理程序,处理程序在worker线程中执行 |
|
||||
|---|---|
|
||||
|
||||
- 使用示例
|
||||
@@ -357,8 +356,12 @@ parentPort.onmessageerror = function(e) {
|
||||
|
||||
### 涉及仓
|
||||
|
||||
- ace_ace_engine
|
||||
- ace_napi
|
||||
- ace_ace_engine(foundation/ace/ace_engine-readme_zh.md)
|
||||
- ace_napi(foundation/ace/napi-readme_zh.md)
|
||||
|
||||
## 相关仓
|
||||
[js_worker_module 子系统](base/compileruntime/js_worker_module-readme_zh.md)
|
||||
|
||||
|
||||
### 许可证
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -14,6 +14,7 @@
|
||||
*/
|
||||
|
||||
#include "message_queue.h"
|
||||
#include "utils/log.h"
|
||||
|
||||
namespace OHOS::CCRuntime::Worker {
|
||||
void MessageQueue::EnQueue(MessageDataType data)
|
||||
@@ -30,9 +31,13 @@ bool MessageQueue::DeQueue(MessageDataType *data)
|
||||
queueLock_.unlock();
|
||||
return false;
|
||||
}
|
||||
*data = queue_.front();
|
||||
queue_.pop();
|
||||
queueLock_.unlock();
|
||||
if (data != nullptr) {
|
||||
*data = queue_.front();
|
||||
queue_.pop();
|
||||
queueLock_.unlock();
|
||||
} else {
|
||||
HILOG_ERROR("worker:: data is nullptr.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@@ -45,7 +45,11 @@ void Worker::StartExecuteInThread(napi_env env, const char* script)
|
||||
if (!runner_) {
|
||||
runner_ = std::make_unique<WorkerRunner>(WorkerStartCallback(ExecuteInThread, this));
|
||||
}
|
||||
runner_->Execute(); // start a new thread
|
||||
if (runner_) {
|
||||
runner_->Execute(); // start a new thread
|
||||
} else {
|
||||
HILOG_ERROR("runner_ is nullptr");
|
||||
}
|
||||
}
|
||||
|
||||
void Worker::CloseInner()
|
||||
@@ -394,7 +398,7 @@ void Worker::WorkerOnMessageInner()
|
||||
}
|
||||
MessageDataType data = nullptr;
|
||||
while (workerMessageQueue_.DeQueue(&data)) {
|
||||
if (data == NULL || IsTerminating()) {
|
||||
if (data == nullptr || IsTerminating()) {
|
||||
HILOG_INFO("worker:: worker reveive terminate signal");
|
||||
TerminateWorker();
|
||||
return;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
|
||||
Reference in New Issue
Block a user