提交 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) {
case "new":
ss = new worker.Worker("workers/worker_0091.js");
console.log("worker:: workerxx ");
ss.onexit = function() {
flag = true;
}
parentPort.postMessage(ss != null);
break;
case "wait":
if (flag) {
parentPort.postMessage("terminate");
}
break;
case "terminate":
flag = false;
ss.terminate();
break;
default:
break;
}
......
......@@ -29,6 +29,10 @@ parentPort.onmessage = function(e) {
backValue = ee.data;
flag = true;
}
ss.onexit = function() {
backValue = "terminate";
flag = true;
}
ss.postMessage(data.value);
break;
case "wait":
......@@ -36,6 +40,10 @@ parentPort.onmessage = function(e) {
parentPort.postMessage(backValue);
}
break;
case "terminate":
flag = false;
ss.terminate();
break;
default:
break;
}
......
......@@ -29,6 +29,10 @@ parentPort.onmessage = function(e) {
backValue = ee.data;
flag = true;
}
ss.onexit = function() {
backValue = "terminate";
flag = true;
}
ss.postMessage({type: "new"});
break;
case "wait":
......@@ -36,6 +40,10 @@ parentPort.onmessage = function(e) {
parentPort.postMessage(backValue);
}
break;
case "terminate":
flag = false;
ss.terminate();
break;
default:
break;
}
......
......@@ -29,6 +29,10 @@ parentPort.onmessage = function(e) {
backValue = ee.data;
flag = true;
}
ss.onexit = function() {
backValue = "terminate";
flag = true;
}
ss.postMessage(data.value);
break;
case "wait":
......@@ -36,6 +40,10 @@ parentPort.onmessage = function(e) {
parentPort.postMessage(backValue);
}
break;
case "terminate":
flag = false;
ss.terminate();
break;
default:
break;
}
......
......@@ -29,6 +29,10 @@ parentPort.onmessage = function(e) {
backValue = ee.data;
flag = true;
}
ss.onexit = function() {
backValue = "terminate";
flag = true;
}
ss.postMessage(data.value);
break;
case "wait":
......@@ -36,6 +40,10 @@ parentPort.onmessage = function(e) {
parentPort.postMessage(backValue);
}
break;
case "terminate":
flag = false;
ss.terminate();
break;
default:
break;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册