未验证 提交 6e1faa9d 编写于 作者: O openharmony_ci 提交者: Gitee

!3691 更新master分支上Worker模块的XTS用例

Merge pull request !3691 from hyq5234/OpenHarmony-3.1-Release
...@@ -17,6 +17,7 @@ import worker from "@ohos.worker" ...@@ -17,6 +17,7 @@ import worker from "@ohos.worker"
const parentPort = worker.parentPort; const parentPort = worker.parentPort;
var ss = undefined; var ss = undefined;
var flag = false;
parentPort.onmessage = function(e) { parentPort.onmessage = function(e) {
let data = e.data; let data = e.data;
...@@ -24,8 +25,20 @@ parentPort.onmessage = function(e) { ...@@ -24,8 +25,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;
} }
......
...@@ -25,7 +25,10 @@ parentPort.onmessage = function(e) { ...@@ -25,7 +25,10 @@ parentPort.onmessage = function(e) {
switch(data.type) { switch(data.type) {
case "new": case "new":
ss = new worker.Worker("workers/worker_0122.js"); ss = new worker.Worker("workers/worker_0122.js");
parentPort.postMessage(ss != null) ss.terminate();
ss.onexit = function() {
parentPort.postMessage(ss != null);
}
break; break;
default: default:
break; break;
......
...@@ -21,5 +21,5 @@ var backValue = undefined; ...@@ -21,5 +21,5 @@ var backValue = undefined;
var flag = false; var flag = false;
parentPort.onmessage = function(e) { parentPort.onmessage = function(e) {
console.log("worker:: thrid worker onmessage") console.info("worker:: thrid worker onmessage")
} }
\ No newline at end of file
...@@ -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;
} }
......
...@@ -25,6 +25,9 @@ parentPort.onmessage = function(e) { ...@@ -25,6 +25,9 @@ parentPort.onmessage = function(e) {
switch(data.type) { switch(data.type) {
case "new": case "new":
ss = new worker.Worker("workers/worker_0151.js"); ss = new worker.Worker("workers/worker_0151.js");
ss.onexit = function() {
parentPort.postMessage(backValue); // 16
}
ss.onmessage = function(ee) { ss.onmessage = function(ee) {
backValue = ee.data; // 16 backValue = ee.data; // 16
flag = true; flag = true;
...@@ -34,7 +37,7 @@ parentPort.onmessage = function(e) { ...@@ -34,7 +37,7 @@ parentPort.onmessage = function(e) {
case "wait": case "wait":
ss.postMessage({type: "wait"}); ss.postMessage({type: "wait"});
if (flag) { if (flag) {
parentPort.postMessage(backValue); // 16 ss.terminate();
} }
break; break;
default: default:
......
...@@ -25,6 +25,9 @@ parentPort.onmessage = function(e) { ...@@ -25,6 +25,9 @@ parentPort.onmessage = function(e) {
switch(data.type) { switch(data.type) {
case "new": case "new":
ss = new worker.Worker("workers/worker_0152.js"); ss = new worker.Worker("workers/worker_0152.js");
ss.onexit = function() {
parentPort.postMessage(backValue); // 16
}
ss.onmessage = function(ee) { ss.onmessage = function(ee) {
backValue = ee.data; backValue = ee.data;
flag = true; flag = true;
...@@ -33,7 +36,7 @@ parentPort.onmessage = function(e) { ...@@ -33,7 +36,7 @@ parentPort.onmessage = function(e) {
break; break;
case "wait": case "wait":
if (flag) { if (flag) {
parentPort.postMessage(backValue); // 16 ss.terminate();
} }
break; break;
default: default:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册