mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-22 05:59:31 +08:00
- Add native worker execution with isolated module state, structured messages, and lifecycle controls. - Support shared buffers and integer atomics with coordinated runtime ownership and cancellation. - Extend compiler, runtime-pack, differential, and compatibility coverage for native concurrency.
12 lines
436 B
TypeScript
12 lines
436 B
TypeScript
import { Worker, isMainThread, parentPort } from "node:worker_threads";
|
|
|
|
if (isMainThread) {
|
|
const worker = new Worker(new URL(import.meta.url));
|
|
worker.on("message", (value: unknown) => console.log("message", value));
|
|
worker.on("exit", (code: number) => console.log("exit", code, "parent alive"));
|
|
} else {
|
|
process.on("exit", (code: number) => parentPort!.postMessage(code));
|
|
process.exit(7);
|
|
console.log("unreachable");
|
|
}
|