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.
34 lines
1.2 KiB
JavaScript
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"] }],
|
|
})),
|
|
],
|
|
};
|
|
}
|