提交 7f045ed2 编写于 作者: W wbdu

Modify the use case of worker

Describe:The worker warehouse has modified the maximum number of
workers, so the test case of the worker needs to be modified.

Issues:https://gitee.com/openharmony/js_worker_module/issues/I4ZPSISigned-off-by: Nwbdu <duwenbo7@huawei.com>
上级 5114e0f5
...@@ -24,8 +24,20 @@ parentPort.onmessage = function(e) { ...@@ -24,8 +24,20 @@ parentPort.onmessage = function(e) {
case "new": case "new":
ss = new worker.Worker("workers/worker_0091.js"); ss = new worker.Worker("workers/worker_0091.js");
console.log("worker:: workerxx "); console.log("worker:: workerxx ");
ss.onexit = function() {
flag = true;
}
parentPort.postMessage(ss != null); parentPort.postMessage(ss != null);
break; break;
case "wait":
if (flag) {
parentPort.postMessage("terminate");
}
break;
case "terminate":
flag = false;
ss.terminate();
break;
default: default:
break; break;
} }
......
...@@ -29,6 +29,10 @@ parentPort.onmessage = function(e) { ...@@ -29,6 +29,10 @@ parentPort.onmessage = function(e) {
backValue = ee.data; backValue = ee.data;
flag = true; flag = true;
} }
ss.onexit = function() {
backValue = "terminate";
flag = true;
}
ss.postMessage(data.value); ss.postMessage(data.value);
break; break;
case "wait": case "wait":
...@@ -36,6 +40,10 @@ parentPort.onmessage = function(e) { ...@@ -36,6 +40,10 @@ parentPort.onmessage = function(e) {
parentPort.postMessage(backValue); parentPort.postMessage(backValue);
} }
break; break;
case "terminate":
flag = false;
ss.terminate();
break;
default: default:
break; break;
} }
......
...@@ -29,6 +29,10 @@ parentPort.onmessage = function(e) { ...@@ -29,6 +29,10 @@ parentPort.onmessage = function(e) {
backValue = ee.data; backValue = ee.data;
flag = true; flag = true;
} }
ss.onexit = function() {
backValue = "terminate";
flag = true;
}
ss.postMessage({type: "new"}); ss.postMessage({type: "new"});
break; break;
case "wait": case "wait":
...@@ -36,6 +40,10 @@ parentPort.onmessage = function(e) { ...@@ -36,6 +40,10 @@ parentPort.onmessage = function(e) {
parentPort.postMessage(backValue); parentPort.postMessage(backValue);
} }
break; break;
case "terminate":
flag = false;
ss.terminate();
break;
default: default:
break; break;
} }
......
...@@ -29,6 +29,10 @@ parentPort.onmessage = function(e) { ...@@ -29,6 +29,10 @@ parentPort.onmessage = function(e) {
backValue = ee.data; backValue = ee.data;
flag = true; flag = true;
} }
ss.onexit = function() {
backValue = "terminate";
flag = true;
}
ss.postMessage(data.value); ss.postMessage(data.value);
break; break;
case "wait": case "wait":
...@@ -36,6 +40,10 @@ parentPort.onmessage = function(e) { ...@@ -36,6 +40,10 @@ parentPort.onmessage = function(e) {
parentPort.postMessage(backValue); parentPort.postMessage(backValue);
} }
break; break;
case "terminate":
flag = false;
ss.terminate();
break;
default: default:
break; break;
} }
......
...@@ -29,6 +29,10 @@ parentPort.onmessage = function(e) { ...@@ -29,6 +29,10 @@ parentPort.onmessage = function(e) {
backValue = ee.data; backValue = ee.data;
flag = true; flag = true;
} }
ss.onexit = function() {
backValue = "terminate";
flag = true;
}
ss.postMessage(data.value); ss.postMessage(data.value);
break; break;
case "wait": case "wait":
...@@ -36,6 +40,10 @@ parentPort.onmessage = function(e) { ...@@ -36,6 +40,10 @@ parentPort.onmessage = function(e) {
parentPort.postMessage(backValue); parentPort.postMessage(backValue);
} }
break; break;
case "terminate":
flag = false;
ss.terminate();
break;
default: default:
break; break;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册