mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 22:02:27 +00:00
Add quickjs-2021-03-27 to third_party
This commit is contained in:
parent
f40f97bd07
commit
1fbfbb3192
67 changed files with 99832 additions and 0 deletions
31
third_party/quickjs/tests/test_worker_module.js
vendored
Normal file
31
third_party/quickjs/tests/test_worker_module.js
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
/* Worker code for test_worker.js */
|
||||
import * as std from "std";
|
||||
import * as os from "os";
|
||||
|
||||
var parent = os.Worker.parent;
|
||||
|
||||
function handle_msg(e) {
|
||||
var ev = e.data;
|
||||
// print("child_recv", JSON.stringify(ev));
|
||||
switch(ev.type) {
|
||||
case "abort":
|
||||
parent.postMessage({ type: "done" });
|
||||
break;
|
||||
case "sab":
|
||||
/* modify the SharedArrayBuffer */
|
||||
ev.buf[2] = 10;
|
||||
parent.postMessage({ type: "sab_done", buf: ev.buf });
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function worker_main() {
|
||||
var i;
|
||||
|
||||
parent.onmessage = handle_msg;
|
||||
for(i = 0; i < 10; i++) {
|
||||
parent.postMessage({ type: "num", num: i });
|
||||
}
|
||||
}
|
||||
|
||||
worker_main();
|
Loading…
Add table
Add a link
Reference in a new issue