diff --git a/compileruntime/worker_lib_standard/src/main/js/default/workers/worker_0121.js b/compileruntime/worker_lib_standard/src/main/js/default/workers/worker_0121.js index 42fb4c47eb5b6fe417095181ba3f5a41c8b1e9e8..862eafab6fb8008fe6923b2ff20bf522f67c606c 100644 --- a/compileruntime/worker_lib_standard/src/main/js/default/workers/worker_0121.js +++ b/compileruntime/worker_lib_standard/src/main/js/default/workers/worker_0121.js @@ -25,7 +25,10 @@ parentPort.onmessage = function(e) { switch(data.type) { case "new": ss = new worker.Worker("workers/worker_0122.js"); - parentPort.postMessage(ss != null) + ss.terminate(); + ss.onexit = function() { + parentPort.postMessage(ss != null); + } break; default: break; diff --git a/compileruntime/worker_lib_standard/src/main/js/default/workers/worker_0122.js b/compileruntime/worker_lib_standard/src/main/js/default/workers/worker_0122.js index 41abfa902d197c06746babd4026bdaa05d435704..e875140b66f4b3663add4bde7864fa9537508338 100644 --- a/compileruntime/worker_lib_standard/src/main/js/default/workers/worker_0122.js +++ b/compileruntime/worker_lib_standard/src/main/js/default/workers/worker_0122.js @@ -21,5 +21,5 @@ var backValue = undefined; var flag = false; parentPort.onmessage = function(e) { - console.log("worker:: thrid worker onmessage") + console.info("worker:: thrid worker onmessage") } \ No newline at end of file diff --git a/compileruntime/worker_lib_standard/src/main/js/default/workers/worker_015.js b/compileruntime/worker_lib_standard/src/main/js/default/workers/worker_015.js index 2e4e0a1f04b41ea720c59bf255b3c44d8d066dae..6f30a0be40b06801fb69a08f1d1f4ea9f9376ade 100644 --- a/compileruntime/worker_lib_standard/src/main/js/default/workers/worker_015.js +++ b/compileruntime/worker_lib_standard/src/main/js/default/workers/worker_015.js @@ -25,6 +25,9 @@ parentPort.onmessage = function(e) { switch(data.type) { case "new": ss = new worker.Worker("workers/worker_0151.js"); + ss.onexit = function() { + parentPort.postMessage(backValue); // 16 + } ss.onmessage = function(ee) { backValue = ee.data; // 16 flag = true; @@ -34,7 +37,7 @@ parentPort.onmessage = function(e) { case "wait": ss.postMessage({type: "wait"}); if (flag) { - parentPort.postMessage(backValue); // 16 + ss.terminate(); } break; default: diff --git a/compileruntime/worker_lib_standard/src/main/js/default/workers/worker_0151.js b/compileruntime/worker_lib_standard/src/main/js/default/workers/worker_0151.js index d9cc1e07a22997acd5f4389c2fee3c3b9c2a433f..1b29a29498c2bc3afb9068bf65bcff9b88a2bf6e 100644 --- a/compileruntime/worker_lib_standard/src/main/js/default/workers/worker_0151.js +++ b/compileruntime/worker_lib_standard/src/main/js/default/workers/worker_0151.js @@ -25,6 +25,9 @@ parentPort.onmessage = function(e) { switch(data.type) { case "new": ss = new worker.Worker("workers/worker_0152.js"); + ss.onexit = function() { + parentPort.postMessage(backValue); // 16 + } ss.onmessage = function(ee) { backValue = ee.data; flag = true; @@ -33,7 +36,7 @@ parentPort.onmessage = function(e) { break; case "wait": if (flag) { - parentPort.postMessage(backValue); // 16 + ss.terminate(); } break; default: diff --git a/compileruntime/worker_lib_standard/src/main/js/test/Worker.test.js b/compileruntime/worker_lib_standard/src/main/js/test/Worker.test.js index 2f8e1c5a4a459dac573d24d43f14cbf616666432..78fdec7d17eaaa40314fa6c823b141ac7b9b51da 100644 --- a/compileruntime/worker_lib_standard/src/main/js/test/Worker.test.js +++ b/compileruntime/worker_lib_standard/src/main/js/test/Worker.test.js @@ -1015,6 +1015,10 @@ describe('workerTest', function () { let res = 0 let flag = false + ss.onexit = function() { + flag = true + } + ss.onmessageerror = function (e) { flag = true res++ @@ -1025,6 +1029,12 @@ describe('workerTest', function () { while (!flag) { await promiseCase() } + + flag = false + ss.postMessage("terminate") + while (!flag) { + await promiseCase() + } expect(res).assertEqual(1) done() }) @@ -1264,12 +1274,15 @@ describe('workerTest', function () { let ss = new worker.Worker("workers/worker_015.js") let flag = false let res = undefined + let isTerminate = false - ss.onmessage = function (e) { + ss.onexit = function() { + isTerminate = true + } + ss.onmessage = function(e) { flag = true res = e.data } - ss.onerror = function(ee) { console.log("worker:: " + ee.message) } @@ -1279,6 +1292,11 @@ describe('workerTest', function () { ss.postMessage({type: "wait"}) await promiseCase() } + ss.terminate() + while (!isTerminate) { + await promiseCase() + } + expect(res).assertEqual(16) done() @@ -1294,8 +1312,13 @@ describe('workerTest', function () { let ss = new worker.Worker("workers/worker_011.js") let flag = false let res = undefined + let isTerminate = false - ss.onmessage = function (e) { + ss.onexit = function() { + isTerminate = true + } + + ss.onmessage = function(e) { flag = true res = e.data } @@ -1317,6 +1340,11 @@ describe('workerTest', function () { await promiseCase() } + ss.terminate() + while (!isTerminate) { + await promiseCase() + } + expect(res).assertEqual("terminate") done() })