interface IWorkerHost
Since 0.1.0

Thread-spawning primitive provided by runtimes that support worker threads. Absent on runtimes without them (e.g. Cloudflare Workers) — consumers MUST degrade gracefully when it is not provided (see the WorkerPoolPlugin, which fails run() with a typed error when no host exists).

Methods

spawn(specifier: string): IWorkerHandle

Spawns a module worker.

Number of threads the host can usefully run in parallel.

Since 0.3.0
optional
reportsExit(): boolean

Reports whether handles from spawn will implement IWorkerHandle.onExit.

Answerable BEFORE a worker exists, which is the reason it sits here rather than being inferred from a handle: a consumer that must warn about — or configure around — undetectable worker death has to know at registration time, and the first spawn may be far later or never happen at all.

Optional so an existing custom host stays valid; a host that omits it is treated exactly as one reporting false.

Usage

import { type IWorkerHost } from "common/src/index.ts";