Files
scriptc/packages/runtime-pack-common/worker-matrix.mjs
Chris Tate 095b619330 Add native workers and shared memory
- 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.
2026-10-07 19:07:02 -05:00

34 lines
1.2 KiB
JavaScript

/** Worker executables use the same runtime ABI with context-local state.
* Every selected runtime object must agree on TLS, including optional units.
* Ordinary and library executables retain their existing object variants. */
export function withWorkerRuntimeVariants(matrix) {
if (matrix.target.object_format === "wasm") return matrix;
const sources = ["scr_worker.c", "scr_worker_events.c", "scr_mailbox.c", "scr_message.c"];
return {
...matrix,
runtime_units: [
...matrix.runtime_units.map((unit) => ({
...unit,
variants: unit.variants.flatMap((variant) => [
{ ...variant, when: { ...variant.when, workers: false } },
...(variant.defines.includes("SCR_DYNAMIC")
? []
: [
{
...variant,
id: `${variant.id}-workers`,
when: { ...variant.when, workers: true },
defines: [...variant.defines, "SCR_WORKERS"],
},
]),
]),
})),
...sources.map((source) => ({
source,
predicate: "workers",
variants: [{ id: "workers", when: { workers: true }, defines: ["SCR_WORKERS"] }],
})),
],
};
}