]> git.kaiwu.me - quickjs.git/commitdiff
test_worker.js: explicitly terminate the worker
authorFabrice Bellard <fabrice@bellard.org>
Mon, 9 Nov 2026 17:16:48 +0000 (18:16 +0100)
committerFabrice Bellard <fabrice@bellard.org>
Mon, 9 Nov 2026 17:16:48 +0000 (18:16 +0100)
tests/test_worker_module.js

index df9358cec58ceaafc700ddf471a9bb703dc30977..ba893f4ae435b2767a2ddf50d697151c8ff3ad98 100644 (file)
@@ -8,17 +8,13 @@ function handle_msg(e) {
     var ev = e.data;
     //          print("child_recv", JSON.stringify(ev));
     switch(ev.type) {
-    case "abort":
-        parent.postMessage({ type: "done" });
-        parent.onmessage = null; /* terminate the worker */
-        break;
     case "sab":
         /* modify the SharedArrayBuffer */
         ev.buf[2] = 10;
         parent.postMessage({ type: "sab_done", buf: ev.buf });
         break;
     case "wait_async":
-        Atomics.waitAsync(ev.buf, 0, 0, Infinity).value.then( () => { parent.postMessage({ type: "done" }); } );
+        Atomics.waitAsync(ev.buf, 0, 0, Infinity).value.then( () => { parent.postMessage({ type: "done" }); parent.onmessage = null; /* terminate the worker */ });
         parent.postMessage({ type: "notify", buf: ev.buf });
         break;
     }