mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-21 05:50:55 +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.
7 lines
358 B
TypeScript
7 lines
358 B
TypeScript
import { Worker, isMainThread } from "node:worker_threads";
|
|
if (isMainThread) {
|
|
const worker = new Worker(new URL(import.meta.url));
|
|
worker.on("error", (error: Error) => console.log(error.name, error.message, error instanceof TypeError));
|
|
worker.on("exit", (code: number) => console.log("exit", code));
|
|
} else { throw new TypeError("worker failed"); }
|