The runtime tracks individual discrete tasks as "workers".

The state of the runtime is dependent on installed workers. Any JS object may be a worker but the runtime's interaction with workers varies as documented here.

If a worker is a PromiseLike the runtime will delete and/or destroy it on completion.

interface Worker {
    [asyncDispose]?: (() => void | Promise<void>);
    [dispose]?: (() => void);
    [label]?: unknown;
    [value]?: unknown;
    construction?: Construction<any>;
    cancel?(): void;
    close?(): void | Promise<void>;
}

Hierarchy

Properties

[asyncDispose]?: (() => void | Promise<void>)

If the worker supports Symbol.asyncDispose the runtime will invoke when the worker is no longer needed. This happens if:

[dispose]?: (() => void)

Workers may implement Symbol.dispose to handle disposal. Works the same as the async equivalent.

[label]?: unknown

If label is present, it will be presented in diagnostics. This takes precedence over [Diagnostic.value].

[value]?: unknown

In diagnostics workers render using toString() unless they provide explicit diagnostics.

construction?: Construction<any>

If the worker supports Construction, the runtime will monitor the worker's lifecycle:

  • If the worker crashed (e.g. experiences an error during initialization) the runtime will cancel all workers and exit

  • If the worker is destroyed the runtime deletes it from the set of known workers

Methods

  • Stop the object's primary activity. This should result in termination as quickly as possible.

    Cancellation have no effect if the object is cancelled or otherwise in a state where cancellation is irrelevant.

    Returns void

  • Returns void | Promise<void>